Skip to main content

I am having trouble connecting to the API at https://developer.vasttrafik.se/portal/. I would like to get the public transport stops (https://developer.vasttrafik.se/portal/#/api/Geography/v1/admin), but I am stuck, I keep getting "HTTP/1.1 403 Forbidden" from the HTTPCaller. I have tried using "Authorization" as suggested at https://community.safe.com/s/question/0D54Q00008WImfCSAT/using-fme-to-call-power-bi-via-the-api-to-refresh-data-sets-dynamically-i-am-stuck-with-the-authentication-piece-for-the-bearer-token, but no success. Any suggestions on what I might be missing?

Have you been able to connect to the API using Postman?

This is the way I work through these projects:

  • Make it work in Postman. (Better geared to get this working.)
  • Transfer the steps to FME.

Thank you for the suggestion. Yes, I am able to get the desired response using Postman. In Postman, I used the address http://api.vasttrafik.se/geo/v1/StopPoints and Authorization - Type: Bearer Token. I guess I´m not configuring this correctly in FME.


Thank you for the suggestion. Yes, I am able to get the desired response using Postman. In Postman, I used the address http://api.vasttrafik.se/geo/v1/StopPoints and Authorization - Type: Bearer Token. I guess I´m not configuring this correctly in FME.

If I try some of these samples (API-konsol) and monitor DevTools (F12) I see:

DevToolsI would try to do:

Authorization


If I try some of these samples (API-konsol) and monitor DevTools (F12) I see:

DevToolsI would try to do:

Authorization

HTTPCallerI have tried Authorization and using the token, but I still get "HTTP/1.1 403 Forbidden".


If I try some of these samples (API-konsol) and monitor DevTools (F12) I see:

DevToolsI would try to do:

Authorization

Is your Content Type set to JSON (application/json)?


If I try some of these samples (API-konsol) and monitor DevTools (F12) I see:

DevToolsI would try to do:

Authorization

HTTPCaller2I added Content-Type = application/json and still get "HTTP/1.1 403 Forbidden".


If I try some of these samples (API-konsol) and monitor DevTools (F12) I see:

DevToolsI would try to do:

Authorization

Hm, swedish is not my first language so it is difficult to reproduce, but I think I have a valid login now.

 

The curl command is:

curl -k -d "grant_type=client_credentials" -H "Authorization: Basic <token>" https://api.vasttrafik.se:443/token

So I think you need 2 httpcallers: 

  • get a temp token from https://api.vasttrafik.se:443/token using the key you got for the app you added.
  • get the data using the temp token you got in the first step.

If I try some of these samples (API-konsol) and monitor DevTools (F12) I see:

DevToolsI would try to do:

Authorization

@magnus​ I can reproduce you issue. I can get a token but then I get a forbidden on the datasets as well. Not sure why but or we are making the same mistake, or it does not work as documented.


The API has now been updated to https://api.vasttrafik.se/geo/v2/StopPoints and I no longer get an error message. However, the _response_body I get is about 10 MB and looks like: 7B2273746F70506F696E7473223A5B7B22676964223A2239303232303134303031303034303031222C2273746F704172656... . I was more hoping for the JSON respons that Postman produces. Any suggestions?

 

Tried with FME 2021.2.2.0.

 

HTTPCaller


The API has now been updated to https://api.vasttrafik.se/geo/v2/StopPoints and I no longer get an error message. However, the _response_body I get is about 10 MB and looks like: 7B2273746F70506F696E7473223A5B7B22676964223A2239303232303134303031303034303031222C2273746F704172656... . I was more hoping for the JSON respons that Postman produces. Any suggestions?

 

Tried with FME 2021.2.2.0.

 

HTTPCaller

Hi @magnus​ , try setting the Response Body Encoding parameter explicitly to appropriate character encoding, maybe UTF-8.


Hi @magnus​ , try setting the Response Body Encoding parameter explicitly to appropriate character encoding, maybe UTF-8.

Yes, that helped. I now get a proper JSON response. Thanks!


Reply