# Debugging Web Request

**URL:** <https://community.easymorph.com/t/debugging-web-request/1307>\
**Category:** General Q&A\
**Created:** [September 23, 2019, 6:24pm UTC](https://community.easymorph.com/t/debugging-web-request/1307 "2019-09-23T18:24:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoctorYSG](https://community.easymorph.com/user_avatar/community.easymorph.com/doctorysg/32/1171_2.png) [@DoctorYSG](https://community.easymorph.com/u/DoctorYSG)\
**Post date:** [September 23, 2019, 6:24pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/1 "2019-09-23T18:24:42Z")

</div>

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).

 ![Annotation](https://community.easymorph.com/uploads/default/original/2X/4/42951373d6659c7fde6b9727a0e61b69469122fe.png)

---

<div class="post-metadata">

**Author:** ![DoctorYSG](https://community.easymorph.com/user_avatar/community.easymorph.com/doctorysg/32/1171_2.png) [@DoctorYSG](https://community.easymorph.com/u/DoctorYSG)\
**Post date:** [September 23, 2019, 6:42pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/2 "2019-09-23T18:42:17Z")

</div>

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
Access-Control-Allow-Origin: *
x-api-key: 0HXJZgldKZjKIXNgIycD4c4DPqSrzn2UFCPHbiR1aY7IW
Authorization: Basic <removed for the post to this forum>
Content-Type: application/x-www-form-urlencoded
Host: pwsepicorapp.draper.com
Content-Length: 83
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

TRI=TRI&+1001=+1001&+1001=+1001&+1001=+1001&+1001=+1001&+1001=+1001&+1001=+1001&A=A

```

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [September 23, 2019, 6:52pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/3 "2019-09-23T18:52:59Z")

</div>

Yes, the Form mode uses `x-www-form-urlencoded` for data encoding. You probably need to construct a JSON in a new column using text concatenation, then use the column as the request body.

---

<div class="post-metadata">

**Author:** ![DoctorYSG](https://community.easymorph.com/user_avatar/community.easymorph.com/doctorysg/32/1171_2.png) [@DoctorYSG](https://community.easymorph.com/u/DoctorYSG)\
**Post date:** [September 23, 2019, 8:56pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/4 "2019-09-23T20:56:56Z")

</div>

I guess you are saying Fiddler is the debug method of choice.

Also, I saw your JSON module, but it does not directly fit the problem here either, I could mod it,  
But my solution looks like something non-programmers would not want to do either:

'{' &  
" Company: " & "'" & [Company] & "', " &  
" Key1: " & "'" & [Key1] & "', " &  
" Key2: " & "'" & [Key2] & "', " &  
" Key3: " & "'" & [Key3] & "', " &  
" Key4: " & "'" & [Key4] & "', " &  
" Key5: " & "'" & [Key5] & "', " &  
" RowMod: " & "'" & [RowMod] & "', " &  
" SerialLot\_c: " & "'" & [SerialLot\_c] & "' " &  
'}'

Looks like a simple transform function could be added to the set of things you have already.  
Something like RowAsJSON()

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [September 23, 2019, 10:14pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/5 "2019-09-23T22:14:19Z")

</div>

We will be adding an action for constructing JSONs in version 4.1. It will work as follows: convert a row into a JSON. If a row value is already a JSON, make it a nested JSON.

Meanwhile, you can use the Table2json module from this example: [Example: Constructing JSON](https://community.easymorph.com/t/example-constructing-json/1279). It basically performs the same construction described above.

---

<div class="post-metadata">

**Author:** ![DoctorYSG](https://community.easymorph.com/user_avatar/community.easymorph.com/doctorysg/32/1171_2.png) [@DoctorYSG](https://community.easymorph.com/u/DoctorYSG)\
**Post date:** [September 24, 2019, 1:29pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/6 "2019-09-24T13:29:49Z")

</div>

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/](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).

---

<div class="post-metadata">

**Author:** ![ckononenko](https://community.easymorph.com/user_avatar/community.easymorph.com/ckononenko/32/7044_2.png) [@ckononenko](https://community.easymorph.com/u/ckononenko)\
**Post date:** [September 24, 2019, 7:28pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/7 "2019-09-24T19:28:30Z")

</div>

> [@DoctorYSG](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![jaws2k](https://community.easymorph.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jaws2k](https://community.easymorph.com/u/jaws2k)\
**Post date:** [September 26, 2019, 6:24am UTC](https://community.easymorph.com/t/debugging-web-request/1307/8 "2019-09-26T06:24:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ckononenko](https://community.easymorph.com/user_avatar/community.easymorph.com/ckononenko/32/7044_2.png) [@ckononenko](https://community.easymorph.com/u/ckononenko)\
**Post date:** [September 26, 2019, 3:13pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/9 "2019-09-26T15:13:48Z")

</div>

@jaws2k thanks for your question.  
If I undertood you correctly, you're trying to interact with a classic [ASP.NET](http://ASP.NET) application.

**Parsing and posting**  
First of all, setup IterateWebRequest action and enable "Return response as the action result" (Response tab) . Thats will create a new column named Response-Body.

A sample response:

```
<input type="hidden" name=" __EVENTTARGET" id="__ EVENTTARGET" value="" />
<input type="hidden" name=" __EVENTARGUMENT" id="__ EVENTARGUMENT" value="" />
<input type="hidden" name=" __VIEWSTATE" id="__ VIEWSTATE" value="MEWFNTAm/8bEuMZaLk3LhgHJ1stgbqFmmw8lqghrR6eJgEpvBUvP00+F0Mlox2Lj2UUDtRoTFA9Zbk4OdmOcTjL+sW/9BxnGJh9dXhWqwH8=" />

```

Next, caclulate a new column named \_\_VIEWSTATE:

```
keepbefore(keepafter(keepbefore(keepafter([Response-Body],'id="__VIEWSTATE"'),'/>'),'"'),'"')

```

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.

**Cookies.**  
Transfering cookies from server to client carried out by header Set-Cookie. Respectively, a new column Set-Cookie will be added to the table.

```
cookie_name=value; path=/

```

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').

---

<div class="post-metadata">

**Author:** ![jaws2k](https://community.easymorph.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jaws2k](https://community.easymorph.com/u/jaws2k)\
**Post date:** [October 9, 2019, 5:14am UTC](https://community.easymorph.com/t/debugging-web-request/1307/10 "2019-10-09T05:14:25Z")

</div>

Many thanks @ckononenko - using these steps I was able to successfully get the values. This has many potential applications...

Thanks again!

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [October 10, 2019, 9:05pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/11 "2019-10-10T21:05:31Z")

</div>

\*\*\*\*\* moved from #Beta lounge to #General Q&A

---

<div class="post-metadata">

**Author:** ![DKcrm](https://community.easymorph.com/user_avatar/community.easymorph.com/dkcrm/32/978_2.png) [@DKcrm](https://community.easymorph.com/u/DKcrm)\
**Post date:** [October 29, 2019, 8:27pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/12 "2019-10-29T20:27:13Z")

</div>

Hi,  
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?

 ![image](https://community.easymorph.com/uploads/default/original/2X/f/f1ed11c50e06167e69fcb74c354219a51afa5872.png)

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [October 29, 2019, 9:36pm UTC](https://community.easymorph.com/t/debugging-web-request/1307/13 "2019-10-29T21:36:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DKcrm](https://community.easymorph.com/user_avatar/community.easymorph.com/dkcrm/32/978_2.png) [@DKcrm](https://community.easymorph.com/u/DKcrm)\
**Post date:** [October 30, 2019, 11:28am UTC](https://community.easymorph.com/t/debugging-web-request/1307/14 "2019-10-30T11:28:59Z")

</div>

That works!

Thank you - Still new and learning on the go 🙂

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [October 30, 2019, 11:41am UTC](https://community.easymorph.com/t/debugging-web-request/1307/15 "2019-10-30T11:41:49Z")

</div>

So do we 🙂

* * *

The topic is now closed. Please open new topics for cases related to Web Request in EasyMorph.

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [October 30, 2019, 11:41am UTC](https://community.easymorph.com/t/debugging-web-request/1307/16 "2019-10-30T11:41:55Z")

</div>

Closed on October 30, 2019, 11:41am UTC


