function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AbiPatAbiPat 

REST API: Getting 'System.CalloutException: Invalid Http response' - Request through postman works fine

I am trying to make a RESTful callout containing a very long string (think: the body length of a typical informative email) as a parameter from Salesforce to Marketo. The callout succeeds when the string is shorter, but fails when the length increases. When I make the exact same callout using postman, it works as expected. Is there any limit on the length of the URL (or anything else) I am missing?

The long string contains the HTML body of an email to be sent out through Marketo, a Marketing tool.
Happy to provide details if needed.
James LoghryJames Loghry
Are you sending the correct headers along from Salesforce?   Are there any special characters in the body that would need escaping (or try to avoid them from being escaped when the request is sent)?  

Have you debugged the request to see if it does in fact look identical to the one you're sending via Postman?
AbiPattyAbiPatty

James, thanks for replying to both my questions! (For others' reference, here's a link to the other question: https://developer.salesforce.com/forums/ForumsMain?id=906F00000005JGD)
 As you might have guessed, they are a part of the same integration.
I am sending the correct headers. In salesforce, I debugged the actual complete URL to see if there are any special characters , and replaced those using string methods with either a blank space or with the right character. I then made the request through salesforce, and it threw the error mentioned above. I copied the exact URL from the debug log, and pasted it in postman. I then added the headers in postman, and voila - it worked there! 

Thoughts?
Alejandro BraunschweigAlejandro Braunschweig

Hello everyone; I happen to be in the same situation: a POST from SF to external REST (sending JSON data) fails from SF (runtime), but works when sent via POSTMAN. To make things even more odd, it works from SF when excuted from the anonymous window.

Can anyone offer some guidance? Thank you for your time.