400 Bad Request "Forbidden"

Asked

Viewed 172 times

-2

I am testing Jasmin through demo version and already created the application and corresponding subscription in Nitrogen.

Through the Postman examples of the Github repository, I can already get the access token "client credentials".

But, when trying to use other endpoints like, for example, the /billing/invoices also available in Postman samples, I always receive a 400 Bad Request with message: "Forbidden".

I’m using Authorization in the form of Bearer Token.

Here comes the body:

GET /api/xxxxxx/xxxxxx-yyyy/billing/invoices HTTP/1.1
Host: my.jasminsoftware.com
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
User-Agent: PostmanRuntime/7.15.0
Accept: */*
Cache-Control: no-cache
Postman-Token: d0c5a19c-5448-4c19-b565-f09d80b7b883,3b40913b-1254-4e82-9370-4a9d0e49974d
Host: my.jasminsoftware.com
accept-encoding: gzip, deflate
Connection: keep-alive
cache-control: no-cache

What could be wrong or missing?

The app we’re trying to integrate is on the Ruby on Rails platform. Here’s the code you were trying to test (using Gem-Rest-client https://github.com/rest-client/rest-client):

require "rest-client"

auth_url = "https://identity.primaverabss.com/core/connect/token"
grant_type = "client_credentials"
scope= "application"
client_id = <CLIENT_ID>
client_secret = <CLIENT_SECRET>
account = <ACCOUNT>
subscription = <SUBSCRIPTION>

response = RestClient.post(auth_url, {grant_type: grant_type, scope: scope, client_id: client_id, client_secret: client_secret})
access_token = JSON.parse(response.body)["access_token"]

host = "https://my.jasminsoftware.com/api" 
endpoint = "billing/invoices"
url = "#{host}/#{account}/#{subscription}/#{endpoint}"

request = RestClient::Request.new(method: :get, url: url, headers: {authorization: "Bearer #{access_token}", accept: "application/json"})
response = request.execute
  • You can put an example of the code?

  • I don’t have any code yet. I’m just trying to evaluate the API through Postman. The problem I am having appears to be exactly the same as this: https://answall.com/questions/397524/400-bad-request-message-forbidden. On the day of its publication, a comment appeared that there was a bug and that it was being solved, but that comment is gone. But I still can’t do anything with the API other than getting the Token.

  • You can then provide the headers and Copes you are asking for?

  • I added the question with the Ruby code I was testing now. I keep getting one 400 Bad Request.

1 answer

3


After watching the video here I realized that I was one step away from making the first call to the API which is to connect the application to the Jasmin subscription here: https://apps.primaverabscom.

After this, the Ruby code I have exposed here works as expected.

Thank you and I hope this information helps other beginners, as is my case.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.