MindSphere URL Access

504 Views Asked by At

I am trying to access Mindsphere URL with Java Code. I am getting 403 forbidden error while doing it. While I am able to hit other POST URL's for other sites, Mindsphere URL is getting blocked by same piece of Java Code. Can someone help? What am i missing in my Code?

restTemplate.exchange(,,*,TimeseriesData.class) is line giving error

1

There are 1 best solutions below

6
On

MindSphere demands a authorization header with a JWT Token, if you call directly the API. I guess you have an Developer account in MindSphere. Try Application credentials in the Developer cockpit. With that credentials you can get a bearer token with an oauth flow.

If not just ping me again.

See Exampel with OK HTTP

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "grant_type=client_credentials");
Request request = new Request.Builder()
  .url("https://questdev.piam.eu1.mindsphere.io/oauth/token")
  .post(body)
  .addHeader("Accept", "application/json")
  .addHeader("cache-control", "no-cache,no-cache")
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .addHeader("Postman-Token", "24126d6b-3461-48fb-9060-6fd005804227")
  .build();

Response response = client.newCall(request).execute();