News:

  • August 04, 2026, 12:31:42 AM

Login with username, password and session length

Author Topic: Training on miscellaneous BRX REST API  (Read 8761 times)

Kristjan

  • Sr. Member
  • ****
  • Posts: 85
    • Idnadartaekni ehf
Training on miscellaneous BRX REST API
« on: June 14, 2023, 06:37:59 AM »
I have a BRX and training on different external API services. Not all services are relevant for industrial automation but I would like to get more confident with integrating towards different REST API services.

I have been reading and parsing successfully from e.g. OpenWeatherMap (with token) and Sunrise-Sunset (without token). Now I am trying out some APIs I found on publicapis.dev and in some cases I get an HTML response "301 Moved Permanently". This was the case with Strava (yes we will have beacons notifying about lack of our training   :D). Is there a way around this 301 response?

Strava tells me the CURL request should be as follows:

Code: [Select]
curl -X GET \
https://www.strava.com/api/v3/athlete \
-H 'Authorization: Bearer YOURACCESSTOKEN'

This works in Postman but not in my PLC. Am I setting up the additional header correctly in the attached image?

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Training on miscellaneous BRX REST API
« Reply #1 on: June 14, 2023, 11:42:27 AM »
I'm not a ton of help here, and since you've done a few other API's I may be wrong, but the Request does not need "https://www.strava.com" in it, only "/api/v3/athlete". Then no "https://" in the Server Name, but not sure about the "www". Also, port 80 is not HTTPS, more typically 443. But I'll be watching along to see what other tips are, as I routinely bang my head against the wall on these setups when I do them.

Additionally, perhaps the ' in combination with the " in your Additional User Request Header isn't helping either.
« Last Edit: June 14, 2023, 11:44:25 AM by Bolt »

Kristjan

  • Sr. Member
  • ****
  • Posts: 85
    • Idnadartaekni ehf
Re: Training on miscellaneous BRX REST API
« Reply #2 on: June 21, 2023, 10:16:22 AM »
You are right, there was a problem in HTTPCMD parameters. Attached request works fine and reads my profile into BRX  8)

The token needs to be refreshed every now and then, this will be a separate HTTPCMD and subsequently parsing out the token string (luckily a short one) and passing it into new requests.

I haven't found a decent value proposition for this integration yet so I'll put further Strava work on hold  ;D But the HTTPCMD and JSON instructions are really opening up the PLC to a whole new world of information!