fraizman
Neuling
Posts: 18
Joined: Sat 31. Oct 2020, 09:02

API : TypeError: NetworkError when attempting to fetch resource.

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
User avatar
mipapo
Administrator
Posts: 1576
Joined: Mon 29. Jul 2013, 20:26
Location: Kiel

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

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
}'
###Become a Runalyze supporter###
- Nutzerhilfe/User help -

Run Happy!,
Michael
P.S. Ich antworte gerne kurz und knackig ;)
Image
fraizman
Neuling
Posts: 18
Joined: Sat 31. Oct 2020, 09:02

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

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.
User avatar
mipapo
Administrator
Posts: 1576
Joined: Mon 29. Jul 2013, 20:26
Location: Kiel

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

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 }'
###Become a Runalyze supporter###
- Nutzerhilfe/User help -

Run Happy!,
Michael
P.S. Ich antworte gerne kurz und knackig ;)
Image
fraizman
Neuling
Posts: 18
Joined: Sat 31. Oct 2020, 09:02

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

It's okay now with a script shell (local .sh) :idea: but not at https://runalyze.com/doc/personal.
Many thanks mipapo :D
User avatar
mipapo
Administrator
Posts: 1576
Joined: Mon 29. Jul 2013, 20:26
Location: Kiel

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

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
###Become a Runalyze supporter###
- Nutzerhilfe/User help -

Run Happy!,
Michael
P.S. Ich antworte gerne kurz und knackig ;)
Image
fraizman
Neuling
Posts: 18
Joined: Sat 31. Oct 2020, 09:02

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

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

Return to “Personal API”