Closed James-kamwendo closed 1 year ago
API logs should tell you what the issue is.
In this case and if what you pasted is accurate, it should be that is_of_device_type
should be spelled is_of__device_type
(note the double underscore between is_of
and device_type
because it's a relationship traversal).
Thank you for responding, the documentation is like this:
curl -X POST \
"https://api.balena-cloud.com/v6/application" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer
and i did this i was getting this: Jamess-MacBook-Pro:~ jameskamwendo$ curl --cacert ca.crt -X POST "https://api.balenaproject.net/v6/application" -H "Content-Type: application/json" -H "Authorization: Bearer HgZNAhxvD4O7kk1qfyJxavz1dmqZo1Xn" --data '{"app_name": "fooled", "device_type": "raspberrypicm4-ioboard"}' -v Note: Unnecessary use of -X or --request, POST is already inferred.
POST /v6/application HTTP/1.1 Host: api.balenaproject.net User-Agent: curl/7.53.1 Accept: / Content-Type: application/json Authorization: Bearer HgZNAhxvD4O7kk1qfyJxavz1dmqZo1Xn Content-Length: 63
so i think i posted a log of what i was just trying after seeing the reponse when i created a fleet with balena cli the json had the is_of__device_type sort of so i thought maybe this might work just being desperate to see it work
is_of__device_type
must be a number, the ID of the device type.
device_type
as per documentation must be a string, the slug of the device type.
Either of the two should work, assuming the API knows about the raspberrypicm4-ioboard
which I understand is a custom one.
Same reponse am getting in django, code snippet is like the following: if request.method == 'POST': api_url = "https://api.balenaproject.net/v6/application"
app_name = request.POST.get('app_name')
device_type = request.POST.get('device_type')
headers_create = {
"Content-Type": "application/json",
"Authorization": f"Bearer {auth_token}"
}
payload = {
"app_name": app_name,
"device_type": device_type
}
print(payload)
# device_type
# response = requests.post(api_url, json=payload, headers=headers_create, verify=True)
response = requests.request('POST', api_url, json=payload, headers=headers_create, verify=True)
print("Response Content:", response)
is_of__device_type
must be a number, the ID of the device type.
device_type
as per documentation must be a string, the slug of the device type.Either of the two should work, assuming the API knows about the
raspberrypicm4-ioboard
which I understand is a custom one.
I retried it with the is_of__device_type and put a number that was assigned to an existing fleet i created with balena cli and i still get this and same thing in postman:
Jamess-MacBook-Pro:~ jameskamwendo$ curl --cacert ca.crt -X POST "https://api.balenaproject.net/v6/application" -H "Content-Type: application/json" -H "Authorization: Bearer HgZNAhxvD4O7kk1qfyJxavz1dmqZo1Xn" --data '{"app_name": "fooled", "is_of__device_type": 65}' -v Note: Unnecessary use of -X or --request, POST is already inferred.
POST /v6/application HTTP/1.1 Host: api.balenaproject.net User-Agent: curl/7.53.1 Accept: / Content-Type: application/json Authorization: Bearer HgZNAhxvD4O7kk1qfyJxavz1dmqZo1Xn Content-Length: 48
POST /v6/application HTTP/1.1 Host: api.balenaproject.net User-Agent: curl/7.53.1 Accept: / Content-Type: application/json Authorization: Bearer HgZNAhxvD4O7kk1qfyJxavz1dmqZo1Xn Content-Length: 50
Sorry, I don't see what's wrong. I'll close the issue as the issue tracker is not for support questions, but please post your issue in our forums, you'll also reach a much wider audience there.
Expected Behavior
Im trying to follow through the API documentation for balena and am using it in django, i've tried to get data from my balena server that is hosted on my local server in virtualbox, and the get request are working just fine but when i try to create say a fleet following the documentation the response is 500 but when i use the balena cli its creating the fleet without a problem so i thought maybe am doing it wrong in django and i tried to curl on terminal the Post request for creating a fleet and i did verbose the response was also 500 but the same endpoint am able to get the fleets i created on balena cli, i tried to curl the delete request this one worked but Posting no, i also tried to patch an existing fleet to Enable automatic update tracking for a fleet using curl it said bad request and ive been trying for 4 days now
Actual Behavior
Jamess-MacBook-Pro:~ jameskamwendo$ curl --cacert ca.crt -X POST "https://api.balenaproject.net/v6/application" -H "Content-Type: application/json" -H "Authorization: Bearer" --data '{"app_name": "fooled", "is_of_device_type": "raspberrypicm4-ioboard"}' -v
Note: Unnecessary use of -X or --request, POST is already inferred.
Specifications