Forum Discussion

rabih's avatar
rabih
Helper
12 years ago

How do I pull third party data in a custom endpoint?

I'm trying to pull a json data object from a third party api to my custom endpoint with no success. I tried http.client.request("http", "host", "url").json().get() but i got something like this: "lithium.coreapi.webui.template.models.HttpClientResponseTemplateModel@<random_code>".

 

Any help is appreciated!

  • Hi rabih,

     

    have you seen the example code in the TKB for using the http client? There is an example using the http.client object to retrieve and process JSON so you should be able to replicate it in your code.

     

    Hope this helps,

3 Replies

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    12 years ago

    Hi rabih,

     

    have you seen the example code in the TKB for using the http client? There is an example using the http.client object to retrieve and process JSON so you should be able to replicate it in your code.

     

    Hope this helps,

  • rabih's avatar
    rabih
    Helper
    12 years ago

    Thanks Paolo. It turns out the response i was getting contains an error: "error making http request: null".

     

    The json object i am trying to pull contains a list like this {"recommendation": [1,2,3,4,5]} and it looks like the http client request cannot handle that. I tried a simple json {"recommendation": "1"} and was able to pull the data. Do you know why this is happening?

     

    Thanks,

     

    -rabih