Jump to content
Sign in to follow this  
Jascha

HTTP POST Data

Recommended Posts

I am missing the possibility to add POST data to an TW3HttpRequest object. I can send a post request with open('POST',...) but I have found to possibility to add the data for the POST request. Is this feature missing or how can I use it?

 

Thank You

Jascha

Share this post


Link to post
Share on other sites

The class is a basic wrapper over the javascript object. I will double check to see what could be wrong. It should support everything a normal javascript users would expect.

PS: Moved your posted to client/server group :)

Share this post


Link to post
Share on other sites

Found it. This article explains the difference between POST and GET:

 

http://www.openjs.com/articles/ajax_xmlhttp_using_post.php

 

I am adding a new method to the RTL: Send(aValue:variant). You are supposed to send the parameters after the channel is open.

 

I suspect the send() method should in reality be invoked inside the OnReadyStateChange event, after checking the ReadyState.

 

You also have to take the server status codes into account, where 200 means OK (im sure you have seen these codes in the browser before).

 

I will post an example on how to do this right shortly!

 

Share this post


Link to post
Share on other sites

Jon,

I need to do the same thing -- use a POST request to an existing server. I do not see the example anywhere. I would really appreciate an example. Have been using your Get implementation for years with good results, and POST requests in Javascript, but no i need to use the POST request in SMS.

Thanks!

Share this post


Link to post
Share on other sites

With the upcoming version 2.1 the RTL has been cleaned up a bit. Along with some other changes, it will include a direct header translation of the W3C specification. With this 'send' should be possible with arbitrary data.

 

However, we do not yet ship an example which features this command. I just added this as feature request to our internal bug tracker. Not sure if it will make it for 2.1, but it's in the system now.

Share this post


Link to post
Share on other sites

The current implementation only allows to send a string (might be in JSON format), if this is sufficient, you can already use this now.

 

In the specification send() is also allowed to pass an ArrayBufferView, Blob or Document beside a string.

 

In addition to the code in the mileage demo, you might also need to specify the content type. Therefore you might want to call

procedure SetRequestHeader(headerName, value: String);

with the parameters: 'Content-Type' and 'text/plain;charset=UTF-8' in case of plain text.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×