Garbage values are coming in http request

Hi @pierce , HTTP Request which was working fine before now showing garbage value, can you please chack this.
Screenshot attached.

Regards,
Sumit

Hi @sumitrathi

Is this screenshot from an HTTP trigger log or from a step making an HTTP request?

HTTP request which I am using in my code. Screenshot attached.


and calling this method like this -
data = await get_price(url)

Regards,
Sumit

Hi @sumitrathi

Thanks for the additional context.

Is it possible this API call is returning a file instead of JSON?

Have you tried setting the Content-Type: application/json specifically as a header in the request?

Lastly, have you tried testing with another tool like Insomnia or Postman to verify that your request is returning JSON outside of your Pipedream step?

If you could provide the entire code step and arguments, that would be helpful if the above troubleshooting steps don’t help.

Yes, I tried with postman and it is returning json. Even same code in other workflow returns json.
Earlier it was working fine but since last few days it is giving this error.

Regards,
Sumit

Have you tried setting the Content-Type: application/json specifically as a header in the request in your Pipedream code step?

If you could provide the entire code step and arguments, that would be helpful if the above troubleshooting steps don’t help.

For instance, we don’t know if you’re using the default axios client or the Pipedream platform extended version.

WHat’s your email id to share the workflow with you

Indeed, have to set the ‘Accept-Encoding’: ‘application/json’ in headers. By default, axios uses gzip and that’s why you’re seeing garbage. In the browser, that usually works without the header, because the browser decompresses it. But in NodeJS it doesn’t.

Hi @bsnelder-hc

First off, welcome to the Pipedream community. Happy to have you!

So you had to define a specific Accept-Encoding header in your axios call? Or did you use some other option in the axios constructor?

Hi @pierce, Thanks! Correct, just set the header. In the authors example pass it into the headers option in the axios constructor. I usually use it like this (.get function):

const { data } = await axios.get(url, {
  headers: {
    'Accept-Encoding': 'application/json'
  }
})
2 Likes

@bsnelder-hc @pierce
I had not given Accept-Encoding in method. I will test and let you guys know. Thanks for your quick reply.

Regards,
Sumit

No error today… Seems the issue was Accept-Encoding which I was not giveing in header.
Thank you guys for your help.

Regards,
Sumit