I am getting the following error on a REST/Odata POST message. The connection “TESTs” ok.
Error: Server returns non successful status code: 400 (Bad Request)
Source: action “Iterate Web request”, table “TGIN-IMU.csv”
I would love to provide more info, but I am not seeing the outgoing HTTP packet., nor the response (I.e. I don’t see how to get this info from EasyMorph). I am going to try to see if I can see it with Fiddler.
I provide a screen shot of the Iterative Web request. (I do know that it is supposed to be a JSON body, with each of these columns).
I can also tell you that is is really painful to put in 7+ fields by selecting column for both the Name and Value. Should there not be a way to say that the incoming table is the body of the POST request in JSON format? (I already removed all extraneous columns).
Ok,Fiddler shows some of the issues. Gotta change this to a JSON body, not a webForm.
POST https://pwsepicorapp.draper.com/ERP10.2Test/api/v1/Ice.BO.UD18Svc/UD18s HTTP/1.1
Authorization: Basic <removed for the post to this forum>
Accept-Encoding: gzip, deflate
Thank you very much for the quick and timely replies. It looks like you guys are on a good path.
BTW: I have been using the SAFE FME (https://www.safe.com/) from vancouver for years for GeoSpatial ETL (and championed it’s use in a lot of projects at our company and in the Air Force). I mention it because they grew from a small company to a pretty large privately owned company and they might have some good lessons for you. (as well as a very friendly ETL tool for Geospatial, which might complement your work).
Thanks for your feedback.
Actually, there is a way how to investigate the request body and headers, as well as server response. You should activate “Return response as the action result” and “Add columns with request headers, body” on Response Tab of WebRequest action.
Any ideas on how we might extract certain fields from the Response - items such as VIEWSTATE ID’s, EVENTSTATE ID’s, or Cookie information for later form posting?
I’m looking at iterating some web requests by building up a POST form and changing certain form fields (i.e date ranges) and downloading/parsing the results.
I’ve got most of the data to build the payload from fiddler, but I think I need to perform a GET on the page first, and then try to inject the authorisation tokens (i.e Viewstate) into the request body prior to the POST.
To send VIEWSTATE back, create another IterateWebRequest action. Set Request method to POST. Configure action Body to Form and add new values. Set __VIEWSTATE as name and bind it to __VIEWSTATE column calculated on a previour step.
Add other required fields.
Pay attention that large viewstate could be chunked into multiple hidden fields by your server.
Transfering cookies from server to client carried out by header Set-Cookie. Respectively, a new column Set-Cookie will be added to the table.
All cookies that were set by the server are automatically sent back from the client on each request. For that purposes a special CookieContainer is used. But CookieContainer will be recreated after each call of Run/RunAction/ReloadNRun, so you should start all actions (Reload and run) together and not one-by-one, otherwise container will be empty. For now, there is no way to set a custom cookie defined by user (even by using header ‘Cookie’).
I’m trying to connect to one of our service providers web service - Initially I need to get a token, which I use for the next hour trying to look up statuses on our orders.
However, I’m not able to get an expected response. As I’m quite new in these web requests, I’m not sure what goes wrong and where…
In the example below, I add a username in the header containing a backslash (\) - In the preview, this is shown as a double backslash (\\).
When Sending the request, I don’t get the response I’m looking for…
Trying to send a request through Postman using the same values, I get the response I need - in Postman, the username and single backslash (\) is shown as expected … Is this the cause of the error? - If so, how do I force EM to only contain a single backslash?
EasyMorph shows the second backslash correctly - a backslash must be escaped with another backslash according to the HTTP specification.
The problem is with the body type in your request. You specified “Body is JSON”, and therefore EasyMorph sends the body as JSON even despite you tried to overwrite the Content-Type header explicitly to application/x-www-formuriencoded which indicates a web-form.
Content-Type application/x-www-formuriencoded in Postman indicates that the request body is not a JSON, but instead a web-form. Also, if you look closely at the request body in Postman you will see that it’s not a JSON (no brackets).
Therefore you need to change body type from JSON to Form. In this case EasyMorph will add Content-Type application/x-www-formuriencoded automatically. No need to explicitly state Content-Type in the Headers tab.