Looking for JSON data from POST

MiServer is Dyalog's APL-based web development framework

Looking for JSON data from POST

Postby woody on Tue Dec 20, 2016 4:24 pm

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
Attachments
POSTJSON2.jpg
POSTJSON1.jpg
Woodley Butler
Automatonics, Inc.
"Find your head in the APL Cloud"
http://www.APLcloud.com
User avatar
woody
 
Posts: 137
Joined: Tue Dec 28, 2010 12:54 am
Location: Atlanta, Georgia USA

Re: Looking for JSON data from POST

Postby Brian|Dyalog on Wed Dec 21, 2016 3:26 am

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:
  1. 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.
  2. 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
User avatar
Brian|Dyalog
 
Posts: 109
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: Looking for JSON data from POST

Postby woody on Sat Dec 24, 2016 3:58 am

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
Woodley Butler
Automatonics, Inc.
"Find your head in the APL Cloud"
http://www.APLcloud.com
User avatar
woody
 
Posts: 137
Joined: Tue Dec 28, 2010 12:54 am
Location: Atlanta, Georgia USA

Re: Looking for JSON data from POST

Postby Brian|Dyalog on Sat Dec 24, 2016 4:29 pm

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
User avatar
Brian|Dyalog
 
Posts: 109
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: Looking for JSON data from POST

Postby woody on Mon Dec 26, 2016 2:19 pm

Bingo !

Yes.. I see the JSON data payload now.

inside req.Content

Perfect.

Thanks, Brian!

//W
Woodley Butler
Automatonics, Inc.
"Find your head in the APL Cloud"
http://www.APLcloud.com
User avatar
woody
 
Posts: 137
Joined: Tue Dec 28, 2010 12:54 am
Location: Atlanta, Georgia USA


Return to MiServer

Who is online

Users browsing this forum: No registered users and 1 guest