user1697063
user1697063

Reputation: 157

Why does Logic App HTTP request fail when response has unknown character

I have a logic app which is making a HTTP GET request to an API. HTTP is failing with the following error.

BadRequest. Http request failed as the content was not valid: 'Unable to translate bytes [9B] at index 790 from specified code page to Unicode.'

I am able to invoke the same API using Postman without an any error, however, I can see in the response that there are some unknown characters.

Does anyone know how I can work around this issue using Azure Logic Apps?

Upvotes: 1

Views: 1184

Answers (1)

Hury Shen
Hury Shen

Reputation: 15754

This problem was caused by the coding of the response from your api, postman will parse the response automatically but HTTP action in logic app will not do it. As I don't know the coding of your data, so just provide some suggestions for your reference.

1. Please check if the response data is in UTF-8. If not, you can use code like below to convert the response data in your api.

UTF8.decode(response.bodyBytes)

2. Add a field Accept in your HTTP action headers.

Accept: text/html;charset=US-ASCII, text/html;charset=UTF-8, text/plain;
charset=US-ASCII,text/plain;charset=UTF-8

Upvotes: 1

Related Questions