Page 1 of 1

Passing request paramaters from SAP MII to server code

Posted: Fri Mar 06, 2015 3:06 pm
by Oscar Silva

I had successfully called a server code from sap mii, but when i try to pass a parameter, it fails.

I've tried everything but i keep seeing on the trace console: "Message (my variable, i assume) can't be empty".

this is the current format from the post data in mii: { data : {"message":"test"} } where the content type i have defined is application/json

Image

Any ideas for why it doesn't work ?

Best Regards


Passing request paramaters from SAP MII to server code

Posted: Sat Mar 07, 2015 12:57 am
by Illya Stepanov

Hi Oscar -

We not familiar with SAP MII, you should find such specialist who will help you set it up correctly for using with REST.


Passing request paramaters from SAP MII to server code

Posted: Sat Mar 07, 2015 2:55 pm
by Oscar Silva

Hi Illya, i also made a js test:

function init(){
var http = new XMLHttpRequest();
var url = "https://api.appery.io/rest/1/code/myr...";
var params = "message=test js";
http.open("POST", url, true);

Code: Select all

//Send the proper header information along with the request 
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
http.setRequestHeader("Content-length", params.length); 
http.setRequestHeader("Connection", "close"); 

http.onreadystatechange = function() {//Call a function when the state changes. 
 if(http.readyState == 4 && http.status == 200) { 
  alert(http.responseText); 
 } 
} 
http.send(params); 

}

same error: Script XXX: Error: Message can't be empty ( @ 42 : 18 ) - throw e; what i'm doing wrong?


Passing request paramaters from SAP MII to server code

Posted: Sat Mar 07, 2015 10:48 pm
by Illya Stepanov

Oscar -

Please explain what you're trying to do with this XMLHttpRequest?

Also you can check our section here, could be helpful - http://devcenter.appery.io/documentat...


Passing request paramaters from SAP MII to server code

Posted: Sun Mar 08, 2015 12:28 am
by Oscar Silva

I have created a server code as follows:

var pushAPIKey = "myPushAPIKey";
var message=request.get("message"); // var message="this works"
var payload = {
"badge" : null,
"message" : message
};
var filter = {
"deviceID" : "theID"
};
PN.send(pushAPIKey, payload, filter);

So, from a server of my own, i'm calling this server code. When i make a post call with no parameters, this code works fine. However, what i want is to call the REST service, and send a custom message via push notification to a device.

I Hope this helps


Passing request paramaters from SAP MII to server code

Posted: Mon Mar 09, 2015 7:28 pm
by Oscar Silva

Hi, i solved this, it turns out that the parameter has to be sent within the url.

Best,