02-25-2020 10:08 - edited 05-04-2020 14:50
02-25-2020 10:08 - edited 05-04-2020 14:50
Over the past several weeks, we’ve received several questions about this announcement. I’ve modified the original announcement to provide more details and clarification about the new requirement that starts May 18, 2020.
According to RFC 7230, section 3.3.2, applications that don’t provide the Transfer-Encoding header, used to define the message body encoding, should include the Content-Length header with the HTTP endpoint request. The Content-Length header allows the application to define the size of the enclosed endpoint body (and message) being sent to Fitbit and denote where the message ends.
When an endpoint request is sent with the Transfer-Encoding header, the Content-Length header is not required. RFC 7230, section 4, defines 5 encoding transformation values for the Transfer-Encoding header: “chunked”, “compress”, “deflate”, “gzip” and a transfer-extension. Fitbit supports the Transfer-Encoding value “chunked”.
Previously, Fitbit did not enforce applications to include the Content-Length header with their HTTP requests. However, our cloud service provider has started enforcing this requirement.
Starting May 18, 2020, Fitbit will begin enforcing applications to use the Content-Length header. The guidelines your application should follow are:
Failure to provide the Content-Length header will result in your application receiving a HTTP Status 411 Length Required “POST requests require a Content-Length header” message for those API calls. We suggest that you start making these changes to your application, now, to prevent disruption in May.
The Fitbit Web API support team will be happy to answer any questions about this information in the forums.
04-06-2020 05:05
04-06-2020 05:05
Hello @Gordon-C,
According to RFC 7230, section 3.3.2:
A sender MUST NOT send a Content-Length header field in any message that contains a Transfer-Encoding header field.
But there is nothing about Transfer-Encoding header in your original post. Could you please clarify if it is enough to send only Transfer-Encoding and not send Content-Length?
04-14-2020 10:18
04-14-2020 10:18
Hi @kostya
My apologies for the delay. That is a very good question. I need to confirm one thing on our side and will respond with an answer shortly. Thank you for your patience.
Gordon
04-17-2020 09:27
04-17-2020 09:27
Hi @kostya
I've updated the announcement to provide more clarity around using the Transfer-Encoding header vs Content-Length header. Please review and let me know if you're still unclear.
Best,
Gordon
05-07-2020 02:58
05-07-2020 02:58
Hi @Gordon-C .
Again, this requirement is for ALL POST PUT and PATCH API calls. This is related to operations involving authorization, refresh tokens, creating subscriptions, and creating or updating new fitbit data logs (i.e. activity, food, sleep, etc.).
What about requests for adding subscriptions? they don't contain body. And also that documentation doesn't mention anything regarding Content-Length header.
Could you please clarify, is it expected that POST requests to add subscriptions must contain Content-Length: 0 headers anyway?
Thanks in advance.
05-07-2020 08:28
05-07-2020 08:28
Hi @falinsky,
Yes, content-length header is required for adding subscriptions even though the request does not contain a body. With that in mind, your request should look like this:
curl -X POST "https://api.fitbit.com/1/user/-/[collection]/apiSubscriptions/[subscriber-id].json"
-H "accept: application/json"
-H "content-length: 0"
-H "authorization: Bearer <access_token>"
I hope this helps! Let us know if you have any questions.
05-07-2020 08:37
05-07-2020 08:37
thank you, @JohnFitbit