Page 1 of 1

API : TypeError: NetworkError when attempting to fetch resource.

Posted: Mon 8. Feb 2021, 09:27
by fraizman
Hello,
i'm testing the /api/v1/metrics/bodyComposition to upload my weight (older data).
I use (i replace the example token with my personal one) in the request body at https://runalyze.com/doc/personal :
curl -s --location --request POST 'https://runalyze.com/api/v1/metrics/bodyComposition' --header 'token: '5cf803010f01c0b2a75b35c7e86ad68b
{
"date_time": "2021-02-08T12:00:00Z",
"weight": 80,
"fat_percentage": 20,
"water_percentage": 60,
"muscle_percentage": 40,
"bone_percentage": 15
}
Then, i click execute and the "Server response" is "TypeError: NetworkError when attempting to fetch resource."
Could you please help me ?
fraizman

Re: API : TypeError: NetworkError when attempting to fetch resource.

Posted: Mon 8. Feb 2021, 09:51
by mipapo
Don't see a problem. I think your curl request is a bit wrong:
Example:

Code: Select all

curl --location --request POST 'https://runalyze.com/api/v1/metrics/bodyComposition' \
--header 'token: xxxxxxx' \
--data-raw '{
  "date_time": "2021-02-08T15:00:00Z",
  "weight": 80,
  "fat_percentage": 20,
  "water_percentage": 60,
  "muscle_percentage": 40,
  "bone_percentage": 12
}'

Re: API : TypeError: NetworkError when attempting to fetch resource.

Posted: Mon 8. Feb 2021, 10:11
by fraizman
Hello mipapo and thanks for your help ;) .

I test your code and the responses are :
curl -X POST "https://runalyze.com/api/v1/metrics/bodyComposition" -H "accept: */*" -H "Content-Type: application/json" -d "curl --location --request POST 'https://runalyze.com/api/v1/metrics/bodyComposition' \\ --header 'token: xxx' \\ --data-raw '{ \"date_time\": \"2021-02-08T10:00:00Z\", \"weight\": 80, \"fat_percentage\": 20, \"water_percentage\": 60, \"muscle_percentage\": 40, \"bone_percentage\": 12 }'"
and
TypeError: NetworkError when attempting to fetch resource.

Re: API : TypeError: NetworkError when attempting to fetch resource.

Posted: Mon 8. Feb 2021, 10:39
by mipapo
Now your curl requests looks totally wrong:
Correct one:

Code: Select all

curl --location --request POST 'https://runalyze.com/api/v1/metrics/bodyComposition' --header 'token: xxxxx' --data-raw '{ "date_time": "2021-02-08T10:00:00Z", "weight": 80, "fat_percentage": 20, "water_percentage": 60, "muscle_percentage": 40, "bone_percentage": 12 }'

Re: API : TypeError: NetworkError when attempting to fetch resource.

Posted: Mon 8. Feb 2021, 17:29
by fraizman
It's okay now with a script shell (local .sh) :idea: but not at https://runalyze.com/doc/personal.
Many thanks mipapo :D

Re: API : TypeError: NetworkError when attempting to fetch resource.

Posted: Mon 8. Feb 2021, 17:53
by mipapo
fraizman wrote: Mon 8. Feb 2021, 17:29 It's okay now with a script shell (local .sh) :idea: but not at https://runalyze.com/doc/personal.
Many thanks mipapo :D
I don't know what you mean. "try out" at that page is not working and that's okay

Re: API : TypeError: NetworkError when attempting to fetch resource.

Posted: Fri 12. Feb 2021, 19:35
by fraizman
It was a typical PEBMAC ("problem exists between monitor and chair") :mrgreen:
The code is okay and the little sh script enables me to upload my older weight data