HTTP Post Request with AddParameter...

Servoy 6.1

I do the following Post and the addParameter is NOT sent ?
The Parameter is returned always as body.
How to fix it and get it work ??

Thank you !

//----------------------------------------------------------------

var client = plugins.http.createNewHttpClient();
var poster = client.createPostRequest(‘http://posttestserver.com/post.php?dump’)

poster.addHeader(‘Host’,‘posttestserver.com’)
poster.addHeader(‘Content-Type’, ‘text/xml’);
poster.addHeader(‘x-amazon-user-agent’, ‘Test-Agent’);
poster.addHeader(‘Content-MD5’,‘mySignature’);
poster.addParameter(‘SignatureVersion’, ‘2’);

poster.setCharset(‘UTF-8’);

var response = poster.executeRequest()
var pageData = response.getResponseBody();

application.output(pageData)

//----------------------------------------------------------------

the code seems to be right. the problem could be the xml returned.
what do you exactly have in your variable pageData?

Some example post code. Note that the addParameter is used to send the body of the request:

/**
* @param {String} url Modifies base URL to go to correct UPS endpoint
* @param {String} body UPS xml string to post
* @return {Object} either err or xml data returned
*  
* @properties={typeid:24,uuid:"F639568D-8098-4750-84FE-31805CF9D851"}
* @AllowToRunInFind
* @private
*/
function _poster(url, body) {
      
   var endpoint = _baseURL + url
   
   // construct poster
   var client = plugins.http.createNewHttpClient();
   var poster = client.createPostRequest(endpoint);
   poster.addHeader('Content-type', 'application/x-www-form-urlencoded')
   poster.addParameter(null, body) //sets the content to post
   
   // send request
   /** @type {String} */
   var responseString   = poster.executeRequest().getResponseBody()
   
   // parse response
   var response = { data : null, err : { code : null, msg : null } }
   
   // error: didn't reach endpoint
   if ( responseString.search(/<\!DOCTYPE/) != -1 ) {
      response.err.code    = "302"
      response.err.msg   = "Endpoint not there"
   }
   else {
      if ( responseString.search(/\n/) != -1) {
         // line breaks in response
         response.data = XML(responseString.substr(responseString.search(/\n/) + 1, 100000))
      }
      else {
         // no line breaks in response
         response.data = XML(responseString.substr(responseString.search(/>/) + 1, 100000))
      }
   }
   
   // error: response returns error
   if ( response.data.Response.Error.ErrorCode ) {
      response.err.code    = response.data.Response.Error.ErrorCode.toString()
      response.err.msg   = response.data.Response.Error.ErrorDescription.toString()
   }
   return response      
}

A quick search for an Amazon example: http://docs.aws.amazon.com/AWSImportExp … quest.html. Looks like the body variable in your case should look something like this:

Action=GetStatus&SignatureMethod=HmacSHA256&JobId=JOBID&AWSAccessKeyId=&SignatureVersion=2&Version=2010-06-03&Signature=%2FVfkltRBOoSUi1sWxRzN8rw%3D&Timestamp=2011-06-20T22%3A30%3A59.556Z