Can't get data from Bosch IoT API

100 Views Asked by At

this is my first question to this great community, so please have mercy.

I currently have following problem:

I want to recieve data from Bosch IoT API, but even following their documentation (https://bosch-iot-insights.com/static-contents/docu/html/Java.html >> Synchronous query execution - Example) didnt help me.

My code looks exactly the same as theirs:

        String resourceUrl = "https://bosch-iot-insights.com/mongodb-query-service/v2/my-project";

        String username = "my-user";
        String password = "my-pw";
        String authorizationCredentials = generateAuthorizationToken( username, password );

        String payload = new String(Files.readAllBytes(Paths.get("C:/Users/my-name/Desktop/payload.json")));
        String contentType = "application/json";


        WebResource service = Client.create().resource( resourceUrl );
        ClientResponse response = service.header( "Authorization", authorizationCredentials )
                .header( "Content-Type", contentType )
                .post( ClientResponse.class, payload );

        System.out.println( response );

        if ( response.getStatus() == 200 ) {
            System.out.println( parseJson( response.getEntity( String.class ) ) );
        } 

I've also tried some solutions with C# and PHP, but they all had the same output: 403 Forbidden When I am opening the project URL I can normally log in, but then I get obviously a 405 Method not allowed - Error, because there is no GET-Method.

I even contacted them and asked for help, but with my credentials they were getting following result:

POST https://bosch-iot-insights.com/mongodb-query-service/v2/my-project/execute-aggregation-query returned a response status of 200 OK
[
  {
    "key": value
  }
]

I know what the Status Code 403 means, but even Bosch can't help me in this problem, because for them everything looked fine..

I'd appreciate and be very grateful if someone could help me or give me some ideas why this error is being produced.
(For more information feel free to ask!)

0

There are 0 best solutions below