10-28-2015 14:02
10-28-2015 14:02
Hello,
When I try to use Adding A Subscription endpoint I am getting following error;
result: {"errors":[{"errorType":"invalid_request","message":"This request should use the https protocol."}],"success":false}
I am actually hitting https endpoint, please see my request below;
POST https://api.fitbit.com/1/user/-//apiSubscriptions/subscription-id_3RXC3L.json HTTP/1.1
Authorization: Bearer [HereIsAValidToken]
Content-Type: application/x-www-form-urlencoded
Host: api.fitbit.com
Content-Length: 0
Connection: Keep-Alive
Response:
HTTP/1.1 301 Moved Permanently
Server: cloudflare-nginx
Date: Wed, 28 Oct 2015 20:47:43 GMT
Content-Length: 0
Connection: keep-alive
Set-Cookie: __cfduid=d121ea89a1269469cb34f26d10c71328e1446065263; expires=Thu, 27-Oct-16 20:47:43 GMT; path=/; domain=.fitbit.com; HttpOnly
X-UA-Compatible: IE=edge,chrome=1
Location: http://api.fitbit.com/1/user/-/apiSubscriptions/subscription-id_3RXC3L.json
X-Frame-Options: SAMEORIGIN
CF-RAY: 23c97f5784fc1882-EWR
And then my HttpClient tries to hit redirected url:
GET http://api.fitbit.com/1/user/-/apiSubscriptions/subscription-id_3RXC3L.json HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: api.fitbit.com
Cookie: __cfduid=d121ea89a1269469cb34f26d10c71328e1446065263
Finally I get following response:
HTTP/1.1 400 Bad Request
Date: Wed, 28 Oct 2015 20:47:43 GMT
Content-Type: application/json;charset=UTF-8
Connection: keep-alive
X-UA-Compatible: IE=edge,chrome=1
Set-Cookie: JSESSIONID=5061D13FA91B82C1B06613EE903E1FCF.fitbit1; Path=/; HttpOnly
Content-Language: en
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
Server: cloudflare-nginx
CF-RAY: 23c97f59ad6e0779-EWR
Content-Length: 116
{"errors":[{"errorType":"invalid_request","message":"This request should use the https protocol."}],"success":false}
Am I missing something?
Best Answer10-28-2015 14:08
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-28-2015 14:08
@reyou wrote:
POST https://api.fitbit.com/1/user/-//apiSubscriptions/subscription-id_3RXC3L.json HTTP/1.1
That's certainly not the expected behavior. Is the double // a typo?
Best Answer10-28-2015 14:14
10-28-2015 14:14
Ah OK now. It works.
I was trying to use following pattern:
POST https://api.fitbit.com/1/user/-/[collection-path]/apiSubscriptions/[subscription-id].json
and in your documentation it is indicated as:
| collection-path | This is the resource of the collection to receive notifications from (foods, activities, sleep, or body). If not present, subscription will be created for all collections. |
That's why I was replacing [collection-path] with an empty string and it was producing double // in the URL.
Thanks for quick response.
Best Answer