Webrequest and iOS error 415

Hi guys, I have some trouble with iOS and webrequest. With android device and simulator no problem, but with iOS I received always error 415.

I realized an app for Nuki Smart Lock and this is a curl:

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer
 API_token' 'https://api.nuki.io/smartlock'

Translate in Monkey:

var url = "https://api.nuki.io/smartlock";                     
var params = {};
var options = {                                             
    :method => Communications.HTTP_REQUEST_METHOD_GET,      
    :headers => {
   	    "Accept" => "application/json",
   	    "Authorization" => "Bearer " + _apiToken
    }
};

Communications.makeWebRequest(url, params, options, method(:onReceive));

I tried with:

"Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED

in a :headers, but same results.

Do you have any idea?

Thanks

  • You have a few debugging options. You might be able to run a dummy server or a proxy (python -m SiimpleHTTPServer 8000 works for most stuff, or you can install fiddler) to capture the incoming request on a computer on your local network and then update the url passed to makeWebRequest to refer to that computer.

    Once you have that, you can compare that to the request sent by curl (you can see the request/response if you pass the --verbose flag). You should be able to compare them to get an idea of what is wrong.

    If you are able to capture the output but need some help figuring out what is going on, please post what you can here; I'll be happy to help. If you figure out the problem let us know too... that way we can get the inconsistency ironed out.

  • Thanks for your reply!

    Yes now I found an iPhone for debugging. I live in Italy and with covid it is not easy to find things Slight smile.

    I will follow your suggestion.

    Thanks