Hi,
I am using AJAX JSON over HTTP to send using CGI. It is working. Does Keil web server CGX supports JSON RPC.
Currently I have to Post JSON using CGX using
$.ajax({ type: "POST", url: "xmlHttp.cgx", data: post_data, contentType: "text/xml", datatype : "text", success: function(data) {
}, error: function (xhr, ajaxOptions, thrownError) {
} });
contentType is xml. If I set JSON/application then I do not get cgi_process_data call.
To add one more question into this thread. Does Keil Embedded HTTP server supports RestFul API as well.
This has been changed recently. Now cgi_process_data() is called on any POST data, not only xml. Please ask support for the updated version.
www.keil.com/.../rlarm_cgi_process_data.htm
I notice that you have the function
void cgi_process_data ( U8 code, /* Type of data in received data buffer. */ U8* dat, /* Pointer to the data string from the POST method. */ U16 len ); /* Number of bytes in the data string. */
code = 0 means a POST with form data operation. code = 4 means a POST with some other data.
So if code is 4, then the user has to call
U8 *http_get_content_type (void);
to check for example if the received data was 'application/json' or whatever the embedded device might want to process.
Can the web server only handle one single page request at a time - or how is the global state of http_get_content_type() handled? How long is it valid? Until cgi_process_data() returns?
Another thing - why does the Keil HTTP documentation specifically discuss Silverlight? Silverlight is one in a million different sources of M2M-communicated data. I feel the manual would do better mentioning lifetime of data than mentioning a MS-specific tool.
HTTP server can handle several sessions simultaneously and can correctly process multiple POST requests at the same time.
The function http_get_content_type() must be called from cgi_process_data() callback. The session instance is internally handled in the library.
Thanks for reply.
I will try ajax calls with contentType: "json/application" and datatype : "json"
instead of
then I will let you know if I get call for CGI post in keil.
"contentType: "json/application"
Why invent your own MIME type?
Sorry It is
Content-Type: application/json
Should this works with keil.
Content-Type: application/json is not working.
I can cheat Keil by either not specifying Content-Type at all then I get code =0 or specify Content-type : text/xml then I get code =4
In both cases it is alight which is I can post/send json data and then I can parse json data but It is not strictly Content-Type: application/json which I am looking.
Only issue is post. response of post is good I can specify "application/json" by override for response.
const char *netCGX_ContentType (void) { return ("application/json"); }
Any thoughts how we can fix it or this is limitation of Keil.
Another question. I cannot find any keil HTTP functions to get request URL. I may like to do RestFul style ajax calls in this case I need to differentiate which method is requested by parsing URL.
As noted from previous post:
This has been changed recently. Now cgi_process_data() is called on any POST data, not only xml. Please ask support for the updated version. http://www.keil.com/support/man/docs/rlarm/rlarm_cgi_process_data.htm
So - have you asked support for the updated version?
I have not ask for updated Keil Middle ware. I have updated my Keil version 5 components which fetch update components over internet from within Keil IDE.
Is there separate process to get manual update from Keil then Kindly let me know how I can get update?
I do have license.
Don't you think Keil's message indicates that they haven't officially released that new version yet? So you can't get it by just retrieving the most recent released version.
"Is there separate process to get manual update from Keil then Kindly let me know how I can get update?"
How about by please asking Keil support for the updated version? Or exactly what do you think Keil staff means when they write "Please ask support for the updated version."???
Thanks for your information.
How I can trigger get cgi_process_data code == 5 because I need to return large JSON response which does not fit into Ethernet/TCP/IP single packet. It is more than 1400 bytes.
Do I need to call AJAX with special parameters.