Oscar Silva
Posts: 0
Joined: Mon Feb 09, 2015 9:26 pm

Passing request paramaters from SAP MII to server code

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Passing request paramaters from SAP MII to server code

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.

Oscar Silva
Posts: 0
Joined: Mon Feb 09, 2015 9:26 pm

Passing request paramaters from SAP MII to server code

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?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Passing request paramaters from SAP MII to server code

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...

Oscar Silva
Posts: 0
Joined: Mon Feb 09, 2015 9:26 pm

Passing request paramaters from SAP MII to server code

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

Oscar Silva
Posts: 0
Joined: Mon Feb 09, 2015 9:26 pm

Passing request paramaters from SAP MII to server code

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

Best,

Return to “Issues”