Why Toybox.Communications makeJsonRequest does not work?

Former Member
Former Member
I'd like to develop an app based on Weather sample provided by the SDK. Weather sample works perfectly.

I'd like to request JSON data from an API like this:
https://api.import.io/store/data/408cfc3b-6ee2-4dea-a2e1-5d4565dad9be/_query?input/webpage/url=http%3A%2F%2Fwww.seha-liga.com%2Frezultati&_user=0af09f30-a925-4df2-a731-fd833c9cce0b&_apikey=0af09f30-a925-4df2-a731-fd833c9cce0b%3AquluZh44DJkSWH5dMGNQpxZxQJWsE%2Fhp1%2B8%2B0M%2BBPBwLsQ9OtXbrqn%2FpDaMbSNQJWIXqvBoDWY%2FlDqzgmsb56w%3D%3D

If you click on the link above, it works in browser.

Anything I try by sending Toybox.Communications features I get 404 as response code. I tried everything, adding the whole URL as request string (see bellow), or with params defined as dictionary in different ways, but could not figure out.

Comm.makeJsonRequest(
"api.import.io/.../_query,
{},
{},
method(:onReceive));

Would you be so king to help me to solve this? Thanks in advance!
  • Former Member
    Former Member over 9 years ago
    https is not functional in the ConnectIQ simulator in version 1.1.1, but it does work on devices with the 1.1.1 SDK. The next SDK release will correct the issue with https in the simulator.

    This may be the cause of the 404 response.

    Also, the response from this request is nearly 9KB, which will take a very long time to transfer over the BLE link to the device, and may be too large for the device to handle when it gets there. You will want to consider filtering this response before sending it to the device.
  • Former Member
    Former Member over 9 years ago
    Okkey, thanks. This data would be filtered in real-wrold use case.
  • Former Member
    Former Member over 9 years ago
    ...and the problem is solved by using http instead of https, thanks very much again!
  • As a note, things work MUCH faster in the simulator than on a real device. Also, I use "phoneConnected" to check if BT is available before doing a makeJsonRequest() so I can display a simple message. But in the simulator, "phoneConnected" is always false (SDK 1.1.1), so you need a flag to bypass the check if in the simulator.