I am trying to use httppost to send an XML string in the body. However, I am receiving an incorrect body when using PostCatcher utility. Here is my code:
I get the following body on Postcatcher server. This resembles JSON format. How can I force it to be plain xml. I have tried setting content type to application/xml without success.
Thanks for your response.
The XML format is
<QueueMessage><MessageText>My message goes here</MessageText></QueueMessage>
The only validation would be ensuring that the text is in format above.
The received body remains the same when I change contentType to text/XML
The received body is empty when I change both contentType and requestContentType to text/XML
I get a response 201 status code which throws an exception. “groovyx.net.http.ResponseParseException: Created”. when I use text/xml for contentType. I get 201 success when I use x-www-form-urlencoded for contentType
The message format is <QueueMessage><MessageText>Encoded base 64 message goes here</MessageText></QueueMessage>
The third party server parses the line above and actually retrieves some data. However, the data that it retrieves is wrong.because of the improperly formatted body.
Using Fiddler, below is a POST that works fine at the third party server. This post was done by .NET client. Notice the body of the XML.
I looked at runscope and I do not see a functionality where runscope act as a server. That is, the request is at runscope. In my case, I want runscope to be accepting my requests.
Below is what I understand of the architecture between runscope and my groovy code Runscope POST ----> Groovy Code
But I am interested in PostCatcher architecture below Groovy Code POST —> Runcode server
[quote=“genii90, post:9, topic:18164”]
"<QueueMessage><MessageText>SGVsbG8gV29ybGQ=</MessageText></QueueMessage>": “”
[/quote]The XML has extra quotes around it, because you are sending using the wrong request content type - it’s not a form post, it’s a raw xml string.
Omit requestContentType completely, and set contentType to application/xml