Giter Club home page Giter Club logo

Comments (6)

dfunckt avatar dfunckt commented on June 21, 2024

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).

from open-balena.

James-kamwendo avatar James-kamwendo commented on June 21, 2024

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 <AUTH_TOKEN>"
--data '{
"app_name": "",
"device_type": ""
}'

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.

  • Trying 192.168.43.207...
  • TCP_NODELAY set
  • Connected to api.balenaproject.net (192.168.43.207) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength
  • successfully set certificate verify locations:
  • CAfile: ca.crt
    CApath: none
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • TLSv1.3 (IN), TLS handshake, Server hello (2):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Unknown (8):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Certificate (11):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, CERT verify (15):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Finished (20):
  • TLSv1.3 (OUT), TLS change cipher, Client hello (1):
  • TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (OUT), TLS handshake, Finished (20):
  • SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
  • ALPN, server did not agree to a protocol
  • Server certificate:
  • subject: CN=*.balenaproject.net
  • start date: Jul 28 13:08:58 2023 GMT
  • expire date: Jul 27 13:08:58 2025 GMT
  • subjectAltName: host "api.balenaproject.net" matched cert's "*.balenaproject.net"
  • issuer: CN=ca.balenaproject.net
  • SSL certificate verify ok.
  • TLSv1.3 (OUT), TLS Unknown, Unknown (23):

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

  • upload completely sent off: 63 out of 63 bytes
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS Unknown, Unknown (23):
    < HTTP/1.1 500 Internal Server Error
    < X-Frame-Options: DENY
    < X-Content-Type-Options: nosniff
    < Vary: X-HTTP-Method-Override
    < Cache-Control: no-cache
    < Date: Thu, 17 Aug 2023 11:55:10 GMT
    < Keep-Alive: timeout=5
    < Transfer-Encoding: chunked
    <
  • Connection #0 to host api.balenaproject.net left intact
    Jamess-MacBook-Pro:~ jameskamwendo$

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

from open-balena.

dfunckt avatar dfunckt commented on June 21, 2024

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.

from open-balena.

James-kamwendo avatar James-kamwendo commented on June 21, 2024

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)

from open-balena.

James-kamwendo avatar James-kamwendo commented on June 21, 2024

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.

  • Trying 192.168.43.207...
  • TCP_NODELAY set
  • Connected to api.balenaproject.net (192.168.43.207) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength
  • successfully set certificate verify locations:
  • CAfile: ca.crt
    CApath: none
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • TLSv1.3 (IN), TLS handshake, Server hello (2):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Unknown (8):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Certificate (11):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, CERT verify (15):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Finished (20):
  • TLSv1.3 (OUT), TLS change cipher, Client hello (1):
  • TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (OUT), TLS handshake, Finished (20):
  • SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
  • ALPN, server did not agree to a protocol
  • Server certificate:
  • subject: CN=*.balenaproject.net
  • start date: Jul 28 13:08:58 2023 GMT
  • expire date: Jul 27 13:08:58 2025 GMT
  • subjectAltName: host "api.balenaproject.net" matched cert's "*.balenaproject.net"
  • issuer: CN=ca.balenaproject.net
  • SSL certificate verify ok.
  • TLSv1.3 (OUT), TLS Unknown, Unknown (23):

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

  • upload completely sent off: 48 out of 48 bytes
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS Unknown, Unknown (23):
    < HTTP/1.1 500 Internal Server Error
    < X-Frame-Options: DENY
    < X-Content-Type-Options: nosniff
    < Vary: X-HTTP-Method-Override
    < Cache-Control: no-cache
    < Date: Thu, 17 Aug 2023 14:16:52 GMT
    < Keep-Alive: timeout=5
    < Transfer-Encoding: chunked
    <
  • Connection #0 to host api.balenaproject.net left intact
    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.
  • Trying 192.168.43.207...
  • TCP_NODELAY set
  • Connected to api.balenaproject.net (192.168.43.207) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength
  • successfully set certificate verify locations:
  • CAfile: ca.crt
    CApath: none
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • TLSv1.3 (IN), TLS handshake, Server hello (2):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Unknown (8):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Certificate (11):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, CERT verify (15):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Finished (20):
  • TLSv1.3 (OUT), TLS change cipher, Client hello (1):
  • TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (OUT), TLS handshake, Finished (20):
  • SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
  • ALPN, server did not agree to a protocol
  • Server certificate:
  • subject: CN=*.balenaproject.net
  • start date: Jul 28 13:08:58 2023 GMT
  • expire date: Jul 27 13:08:58 2025 GMT
  • subjectAltName: host "api.balenaproject.net" matched cert's "*.balenaproject.net"
  • issuer: CN=ca.balenaproject.net
  • SSL certificate verify ok.
  • TLSv1.3 (OUT), TLS Unknown, Unknown (23):

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

  • upload completely sent off: 50 out of 50 bytes
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS Unknown, Unknown (23):
    < HTTP/1.1 500 Internal Server Error
    < X-Frame-Options: DENY
    < X-Content-Type-Options: nosniff
    < Vary: X-HTTP-Method-Override
    < Cache-Control: no-cache
    < Date: Thu, 17 Aug 2023 14:17:05 GMT
    < Keep-Alive: timeout=5
    < Transfer-Encoding: chunked
    <
  • Connection #0 to host api.balenaproject.net left intact
    Jamess-MacBook-Pro:~ jameskamwendo$

from open-balena.

dfunckt avatar dfunckt commented on June 21, 2024

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.

from open-balena.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.