POSTING plain text via a property to a REST Service
Hi,
I feel a bit of a dunce posting this message, cos it should be straight forward - but it;s not working!
I have a REST resource, method, request setup which I intend to POST to, but the content of the request doesn't have any XML its sourced from a flat text file in the following format:
CustRefID|title|firstname|lastname|addressline1|addressline2|addressline3|postcode ID0000001|MR|RICH|JONES|5 WHATEVER WAY|HODGE HILL|BIRMINGHAM|B36 9LB Rows=1
I have a property created on the Testsuite (and I am sourcing the property '${#TestSuite#fileContents}') on the 'Request' form that contains the contents of the above file but when I tried submitting the POST request, the 'Form' tab indicates that I get an apache error saying 'unexpected element: CDATA'
I thought the problem was something to do with the Media Type: so I've set it to 'text/xml' (on the 'Request' tab) but it's still not working. I changed the type to various other options but none of them worked. I've had a look on this forum and I did find something on attachments (that I also couldnt get to work) but nothing that really helped.
My Web Services Testing with SoapUI book is also very good, but doesn't answer my question.
Any help advice/guidance anyone can provide would be great!
I've attached a screenshot and my project file if anyone wants to have a look
Many thanks!
richie
Hello Richie,
Thanks for posting in the SmartBear Community Forum.
The error you are receiving is due to the message body not being in XML format.
To solve the immediate error, you should modify the body to:
<file_contents>${#TestSuite#fileContents}</file_contents>
As a side note, I would recommend sending the data as an attachment since it is easier to manage if the data gets larger (if that is the case). https://support.smartbear.com/readyapi/docs/projects/requests/attachment/rest.html