Page 1 of 1

Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Thu Sep 15, 2016 2:58 am
by tcbeaton

I have tried numerous times to get an API Express implementation of sending channel information back to Appery for a device. The response shows the correct channel values, and returns a 200 OK status, but checking the Devices DB does not reflect the channel request.


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Thu Sep 15, 2016 5:30 am
by Serhii Kulibaba

Hello,

Could you clarify, how do you update these values? Please send us a screenshot with it?


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Thu Sep 15, 2016 6:31 am
by tcbeaton

Below is a screen shot of how I currently have it configured. I've also tried putting the deviceID directly in the ServiceURL, and tried putting channels and deviceID in the Request Header Parameters. In all cases, when I click on Generate I get 200 OK along with the rest of the response. Thanks.

Image


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Fri Sep 16, 2016 9:59 am
by Serhii Kulibaba

1) You use a device registration request instead of sending. Please look at this link, which URL you have to use there: https://docs.appery.io/reference#push...

2) Please add a value of the X-Appery-App-Id, it can't be an undefined


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Fri Sep 16, 2016 11:27 am
by tcbeaton

Sergiy, I put the X-Appery-App-Id in when I click Generate in API Express, but results are still wrong!

1) Here's the database before I click "Generate":
Image

2) Here's how I'm filling out the fields:
Image

3) Here's the response to "Run REST API" (note: "updatedAt" shows current timestamp, but channels is [4]; server HTTP_RESPONSE_CODE" is "200"):
[quote:]
{
"BODY": {
"id": "57d20173e4b071c20d9ade79",
"token": "c443IDPbFpA:APA91bFh_N1eFpuyHPGW6PQaAryuQBut7LI0tkYoReTgYtZkW-rxI_NPuSuMf4plLHnKLY5Emc9kUoOEEqUKwZABzFJNeQPqlk5LDgnLYLnErWtcK2XkU-XDFhOMHI0Bo_0QkgFsvYjF",
"deviceID": "b10693f5cdfd3a33",
"timeZone": "GMT-04:00",
"type": "A",
"createdAt": "2016-09-09 00:25:23.518",
"updatedAt": "2016-09-16 11:21:08.366",
"channels": [
4
]
},
"HTTP_RESPONSE_HEADERS": {
"Strict-Transport-Security": "max-age=15768000",
"Transfer-Encoding": "chunked",
"Date": "Fri, 16 Sep 2016 11:21:08 GMT",
"X-Appery-App-Id": "38bc4817-4381-4cf1-a296-90330f6ec7c8",
"Content-Type": "application/json",
"Connection": "keep-alive",
"Server": "nginx"
},
"HTTP_RESPONSE_CODE": 200
}
[/quote]

4) Here's the database afterwards (note: shows update timestamp, but still shows [4], not [1,3]):
Image


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Fri Sep 16, 2016 1:44 pm
by Serhii Kulibaba

Please set a request parameter "body":

prerequestBody = {channels:JSON.parse(PARAMS.QUERY.channels)};/pre

So your parameters should be, like:
Image


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Fri Sep 16, 2016 7:51 pm
by tcbeaton

Hi Sergiy, Still no luck. Below are the two screenshots. After I "Run REST API" the database is still showing "[4]" for the channels.
Image
Image
code
{
"BODY": {
"id": "57d20173e4b071c20d9ade79",
"token": "c443IDPbFpA:APA91bFh_N1eFpuyHPGW6PQaAryuQBut7LI0tkYoReTgYtZkW-rxI_NPuSuMf4plLHnKLY5Emc9kUoOEEqUKwZABzFJNeQPqlk5LDgnLYLnErWtcK2XkU-XDFhOMHI0Bo_0QkgFsvYjF",
"deviceID": "b10693f5cdfd3a33",
"timeZone": "GMT-04:00",
"type": "A",
"createdAt": "2016-09-09 00:25:23.518",
"_updatedAt": "2016-09-16 19:49:42.789",
"channels": [
4
]
},
"HTTP_RESPONSE_HEADERS": {
"Strict-Transport-Security": "max-age=15768000",
"Transfer-Encoding": "chunked",
"Date": "Fri, 16 Sep 2016 19:49:42 GMT",
"X-Appery-App-Id": "38bc4817-4381-4cf1-a296-90330f6ecxxx",
"Content-Type": "application/json",
"Connection": "keep-alive",
"Server": "nginx"
},
"HTTP_RESPONSE_CODE": 200
}
/code


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Mon Sep 19, 2016 8:07 am
by Serhii Kulibaba

Please use a service Test tab fro the testiong, instead of "generate response". Image

As you can see on the screenshot below, it works fine: Image


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Mon Sep 19, 2016 3:34 pm
by tcbeaton

Thank you, Sergiy! :-) Finally, it worked.

Just out of curiosity, why would the "Generate Response" option not work, since that's already on that page?


Is it possible to get an example/tutorial on how to set-up API Express to send channel information to Devices database f

Posted: Tue Sep 20, 2016 1:58 pm
by Serhii Kulibaba

It also works fine (you did't fill a request body field)

Please look at the example below: Image