You need to sign in to do that
Don't have an account?
Daniel Ebel
Callout response exception: Illegal character sequence '\/' in string literal.
Hello everyone,
this is my first question here, so please let me know if there's anything I can do to help you solve my problem quicker.
Setup:
I'm sending a callout request in order to receive a response in JSON which contains a link to a website. The request looks like this:
When I enter the callout request in my browser I get the following response:
Problem
When I try to debug the response's body, I get the following error: System.CalloutException: Could not parse HTTP response body to string
When I take the string I got from the browser and try to debug it, I get the following error:
ERROR deploying ApexClass classes/SendEkomiReviewRequest.cls: Invalid string literal '{"link":"https:\/\/www.ekomi.de\/kundenmeinung.php?kunde=customerId&shop=accountId","hash":"2f68e87f2ba63a7929798400c372126b","known_since":"2017-07-24","done":1,"done_at":1500897547}'. Illegal character sequence '\/' in string literal.
Is there a way of altering the response I'm getting before it's parsed, so I can eventually deserialize it?
Thanks for your help!
Daniel
this is my first question here, so please let me know if there's anything I can do to help you solve my problem quicker.
Setup:
I'm sending a callout request in order to receive a response in JSON which contains a link to a website. The request looks like this:
http://api.ekomi.de/v3/putOrder?auth=accountId|password&order_id=E10002&version=cust-1.0.0&type=jsonThe response I'm getting is System.HttpResponse[Status=OK, StatusCode=200]
When I enter the callout request in my browser I get the following response:
{"link":"https:\/\/www.ekomi.de\/kundenmeinung.php?kunde=customerId&shop=accountId","hash":"2f68e87f2ba63a7929798400c372126b","known_since":"2017-07-24","done":1,"done_at":1500900539}
Problem
When I try to debug the response's body, I get the following error: System.CalloutException: Could not parse HTTP response body to string
When I take the string I got from the browser and try to debug it, I get the following error:
ERROR deploying ApexClass classes/SendEkomiReviewRequest.cls: Invalid string literal '{"link":"https:\/\/www.ekomi.de\/kundenmeinung.php?kunde=customerId&shop=accountId","hash":"2f68e87f2ba63a7929798400c372126b","known_since":"2017-07-24","done":1,"done_at":1500897547}'. Illegal character sequence '\/' in string literal.
Is there a way of altering the response I'm getting before it's parsed, so I can eventually deserialize it?
Thanks for your help!
Daniel
As mentioned, when I try to parse the response's body in a string or try to deserialize it with getBody(), I get the error message mentioned above.
The solution is to not get the response as a string but instead as a blob and then convert it to a string:
This way, I don't get the error message and i can deserialize the responseBody string.
All Answers
As mentioned, when I try to parse the response's body in a string or try to deserialize it with getBody(), I get the error message mentioned above.
The solution is to not get the response as a string but instead as a blob and then convert it to a string:
This way, I don't get the error message and i can deserialize the responseBody string.