API connection
The API is hosted at the following link:
APIURL = https://api.captahydro.com
To connect, in EACH request you must send the credentials that are the identifier of the
organization plus the API Key. Both must be sent within the header of the query, in the following
Format:
APIKey:{API_KEY_GENERATED}
OrganizationId:{ORGANIZATION_ID}
API Features
In the provided link of the API, the following queries can be made:
devices: Request type GET
device{deviceId}: Request type GET
device{deivceId}/data: Request type GET
/devices
GET type request:
Gets the organization's devices and those that were shared with the organization.
Response format: If the response is wrong, it returns an error. In case of being
successful, it returns in JSON format, an array with the data of each device. This contains
always:
id : device identifier
name: name of the device (in amaru) And depending on the type of device, it returns the
last value measured by your sensors plus the time of the sensor measurement (in the format of
unix timestamp in milliseconds).
I think I figured out that I should send it as an array array(
'APIKey: 4c823e19-e47a-493f-8837-ade4efea9dfc',
'OrganizationId: 29'), but I don't know how to add this array to the head?
You can try the request against https://httpbin.org/anything from both postman and B4J and see if you can spot any differences. Just don't use your real api key. Also make sure you are using the correct Api key. If you are copying/pasting the key, make sure you're not accidentally including "hidden" characters
his key is valid. the error is a 403 which means authentication is correct, but there is
an authorization issue. he can get in the front door, but not to a higher story. the error
reported is typical of amazon aws, and you can see references to amazon aws in
postman's response. i wish he would post the full documentation. i'm thinking there is
something missing in what he's told us.
i also tried using an okhttp3 client directly (essentially what okhttputils2 does) in the
very unlikely event okhttputils2 does something the server doesn't like, but the error was
the same.
it can be done with a browser and ajax. i get the same answer as with postman. chrome doesn't allow cors error, so i had to use (god forbid) ie. browser tacks on additional headers. maybe these are what server wants. i'm going to apply them to okhttputils2 request to see if that makes a difference. heading for breakfast now.
You can try the request against https://httpbin.org/anything from both postman and B4J and see if you can spot any differences. Just don't use your real api key. Also make sure you are using the correct Api key. If you are copying/pasting the key, make sure you're not accidentally including "hidden" characters
it can be done with a browser and ajax. i get the same answer as with postman. chrome doesn't allow cors error, so i had to use (god forbid) ie. browser tacks on additional headers. maybe these are what server wants. i'm going to apply them to okhttputils2 request to see if that makes a difference. heading for breakfast now.
Thank you very much, I tried with https://httpbin.org/anything and you can see the results below the head are almost the same with the exception of Postman-Token
Unless you, for some reason, are changing the 3455 from the B4J app to 8837 in Postman, the displayed portion of the API keys do not match, therefore you may not be using the same key for B4J as for Postman. Please make sure you're actually using the same API keys (right now it looks like you are not). Alternative, you could copy the B4J key (if they differ) into Postman and check the result(s)