Looking for JSON data from POST
5 posts
• Page 1 of 1
Looking for JSON data from POST
Greetings,
I have been referencing both req.Arguments and req.Data with success when looking at passed parameter names and values from both GET and POST methods sent to MiServer 2.0.
However, I have a front-end Javascript (AngularJS) web page that is trying to send an HTTP POST that includes a string of JSON "DATA" characters.
When I use Fiddler2 (debugging tool) I clearly see the JSON data sent by the browser ... but I can not seem to find this data anywhere in MiServer 2.0.
(See attached screen shots)
I assume the JSON data is somewhere in the header ?
How can I extract this JSON DATA out of the received POST transaction sent to my MiServer?
Sincere thanks!
//W
I have been referencing both req.Arguments and req.Data with success when looking at passed parameter names and values from both GET and POST methods sent to MiServer 2.0.
However, I have a front-end Javascript (AngularJS) web page that is trying to send an HTTP POST that includes a string of JSON "DATA" characters.
When I use Fiddler2 (debugging tool) I clearly see the JSON data sent by the browser ... but I can not seem to find this data anywhere in MiServer 2.0.
(See attached screen shots)
I assume the JSON data is somewhere in the header ?
How can I extract this JSON DATA out of the received POST transaction sent to my MiServer?
Sincere thanks!
//W
-
woody - Posts: 144
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
Re: Looking for JSON data from POST
Hi Woody,
The reason the data isn't in the HTTPRequest instance is because HTTPRequest recognizes a limited number of Content-Types (MIME types) (currently multipart/form-data, application/x-www-form-urlencoded, and text/plain) and your request has a Content-Type of application/json.
There are a couple of ways to address this:
I hope this helps!
/Brian
The reason the data isn't in the HTTPRequest instance is because HTTPRequest recognizes a limited number of Content-Types (MIME types) (currently multipart/form-data, application/x-www-form-urlencoded, and text/plain) and your request has a Content-Type of application/json.
There are a couple of ways to address this:
- Add specific support for additional MIME types. This probably makes sense for a number of common subset including application/json. This is going to take a bit of time to design and implement.
- Add a Content public field to the HTTPClass that will contain the request's content in the event that the Content-Type is one of those we don't specifically support. This is a no-brainer and I've made the change to both MiServer 2 and 3. You can download the latest MiServer 2 from https://github.com/Dyalog/MiServer/archive/MiServer2.zip
I hope this helps!
/Brian
-
Brian|Dyalog - Posts: 120
- Joined: Thu Nov 26, 2009 4:02 pm
- Location: West Henrietta, NY
Re: Looking for JSON data from POST
Thanks!
I downloaded the updated version of MS 2.1 ... and got it running.
I tried the POST action from the front-end AngularJS JavaScript web browser ...
But, I do not see anything new in the passed parameters.
How do I get my hands on the passed JSON data?
Here's what I see:
⍴ req.Data
0 2
⍴ req.Arguments
2 2
req.Arguments
Page WebService
Function PUTROOMDATA
req.Headers
host gomockup.com
content-length 575
accept application/json, text/plain, */*
origin http://gomockup.com
user-agent Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
content-type application/json;charset=UTF-8
referer http://gomockup.com/
accept-encoding gzip, deflate
accept-language en-US,en;q=0.8
cookie Session=buoXXqK0bE/aU/h3bTjX4c6DAIQGpm4jt9nJX9G1iDc=
via 1.1 CWS_proxy
x-forwarded-for 71.204.44.89
cache-control max-age=259200
connection keep-alive
Thoughts?
//W
I downloaded the updated version of MS 2.1 ... and got it running.
I tried the POST action from the front-end AngularJS JavaScript web browser ...
But, I do not see anything new in the passed parameters.
How do I get my hands on the passed JSON data?
Here's what I see:
⍴ req.Data
0 2
⍴ req.Arguments
2 2
req.Arguments
Page WebService
Function PUTROOMDATA
req.Headers
host gomockup.com
content-length 575
accept application/json, text/plain, */*
origin http://gomockup.com
user-agent Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
content-type application/json;charset=UTF-8
referer http://gomockup.com/
accept-encoding gzip, deflate
accept-language en-US,en;q=0.8
cookie Session=buoXXqK0bE/aU/h3bTjX4c6DAIQGpm4jt9nJX9G1iDc=
via 1.1 CWS_proxy
x-forwarded-for 71.204.44.89
cache-control max-age=259200
connection keep-alive
Thoughts?
//W
-
woody - Posts: 144
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
Re: Looking for JSON data from POST
Hi Woody,
The payload (content) of the request is now found in REQ.Content (MiServer 2) or _Request.Content (MiServer 3). That's what I tried to convey in my previous post when I said "Add a Content public field".
I hope this helps!
/Brian
The payload (content) of the request is now found in REQ.Content (MiServer 2) or _Request.Content (MiServer 3). That's what I tried to convey in my previous post when I said "Add a Content public field".
I hope this helps!
/Brian
-
Brian|Dyalog - Posts: 120
- Joined: Thu Nov 26, 2009 4:02 pm
- Location: West Henrietta, NY
Re: Looking for JSON data from POST
Bingo !
Yes.. I see the JSON data payload now.
inside req.Content
Perfect.
Thanks, Brian!
//W
Yes.. I see the JSON data payload now.
inside req.Content
Perfect.
Thanks, Brian!
//W
-
woody - Posts: 144
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group