DJI TerraAPI "DELETE"

Completed

Comments

20 comments

  • DJI Developer Support
    Dear Developer, Hello and thank you for reaching out to DJI Innovations. The URL does not need to be used as a string. We hope that our solution meets your needs satisfactorily. We appreciate your email and wish you a wonderful day! Best Regards, DJI Innovations SDK Technical Support Team
    1
    Comment actions Permalink
  • jabanat

    Thanks for your quick response! Unfortunately I am still getting the same response:

    #!/bin/bash

    DJI_APP_KEY=""
    DJI_SECRET_KEY=""
    URI=/terra-rescon-be/v2/resources/85910e50-b3e8-414e-b80d-7edd7ef49fae
    HTTP_METHOD=DELETE

    function calculate_signature() {
    content="$1"
    signature=$(echo-n-e"${content}" | openssldgst-sha256-hmac"${DJI_SECRET_KEY}"-binary | opensslenc-base64-A)
    echo ${signature}
    }

    HOST=https://openapi-us.dji.com

    url=${HOST}${URI}
    x_date=$(date -u +"%a, %d %b %Y %H:%M:%S GMT")
    lower_method=$(echo "${HTTP_METHOD}" | tr '[:upper:]' '[:lower:]')
    digest=$(echo -n "${payload}" | openssl dgst -sha256 -binary | base64)
    request_signature=$(calculate_signature "date: ${x_date}\n@request-target: ${lower_method} ${URI}\ndigest: SHA-256=${digest}")

    curl -X ${HTTP_METHOD} ${url} \
    -H"Date: ${x_date}"\
    -H"Digest: SHA-256=${digest}"\
    -H"Authorization: hmac username=\"${DJI_APP_KEY}\", algorithm=\"hmac-sha256\", headers=\"date @request-target digest\", signature=\"${request_signature}\""\
    -H'Content-Type: application/json;charset=UTF-8' -v
    The curl verbose response is:
    * Host openapi-us.dji.com:443 was resolved.
    * IPv6: (none)
    * IPv4: 44.195.198.113, 44.216.133.164
    *   Trying 44.195.198.113:443...
    * Connected to openapi-us.dji.com (44.195.198.113) port 443
    * ALPN: curl offers h2,http/1.1
    * (304) (OUT), TLS handshake, Client hello (1):
    *  CAfile: /etc/ssl/cert.pem
    *  CApath: none
    * (304) (IN), TLS handshake, Server hello (2):
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 / [blank] / UNDEF
    * ALPN: server accepted h2
    * Server certificate:
    *  subject: CN=*.dji.com
    *  start date: Nov 27 00:00:00 2023 GMT
    *  expire date: Dec 24 23:59:59 2024 GMT
    *  subjectAltName: host "openapi-us.dji.com" matched cert's "*.dji.com"
    *  issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M02
    *  SSL certificate verify ok.
    * using HTTP/2
    * [HTTP/2] [1] OPENED stream for https://openapi-us.dji.com/terra-rescon-be/v2/resources/85910e50-b3e8-414e-b80d-7edd7ef49fae
    * [HTTP/2] [1] [:method: DELETE]
    * [HTTP/2] [1] [:scheme: https]
    * [HTTP/2] [1] [:authority: openapi-us.dji.com]
    * [HTTP/2] [1] [:path: /terra-rescon-be/v2/resources/85910e50-b3e8-414e-b80d-7edd7ef49fae]
    * [HTTP/2] [1] [user-agent: curl/8.7.1]
    * [HTTP/2] [1] [accept: */*]
    * [HTTP/2] [1] [date: Wed, 31 Jul 2024 11:41:03 GMT]
    * [HTTP/2] [1] [digest: SHA-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=]
    * [HTTP/2] [1] [authorization: hmac username="[USERNAME]", algorithm="hmac-sha256", headers="date @request-target digest", signature="[SIGNATURE]"]
    * [HTTP/2] [1] [content-type: application/json;charset=UTF-8]
    * [HTTP/2] [1] [content-length: 0]
    > DELETE /terra-rescon-be/v2/resources/85910e50-b3e8-414e-b80d-7edd7ef49fae HTTP/2
    > Host: openapi-us.dji.com
    > User-Agent: curl/8.7.1
    > Accept: */*
    > Date: Wed, 31 Jul 2024 11:41:03 GMT
    > Digest: SHA-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
    > Authorization: hmac username="[USERNAME]", algorithm="hmac-sha256", headers="date @request-target digest", signature="[SIGNATURE]"
    > Content-Type: application/json;charset=UTF-8
    > Content-Length: 0

    * Request completely sent off
    < HTTP/2 400 
    < date: Wed, 31 Jul 2024 11:41:05 GMT
    < content-type: application/json; charset=utf-8
    < content-length: 91
    < request-id: terra-rescon-be-1742145-2-7d94899b45-jhkfh-f5a06394-e0ec-4deb-8811-0187dea47d8d
    < tracer-id: 0630c0b8466746ba8edda4f738aec2be
    < x-kong-upstream-latency: 7
    < x-kong-proxy-latency: 0
    < via: nw
    < x-nw-trace-id: 26d69a38b0e61f00faaabf20ac2372f7
    < x-nw-response-type: ki_upstream_response

    * Connection #0 to host openapi-us.dji.com left intact
    {"result":{"code":102001,"msg":"invalid param: query or form param","desc":"InvalidParam"}}%   
    0
    Comment actions Permalink
  • a2499908981

    I also have this problem, waiting for the response...

    1
    Comment actions Permalink
  • DJI Developer Support
    Dear Developer, Hello and thank you for reaching out to DJI Innovations. The payload cannot be omitted. We hope that our solution meets your needs satisfactorily. We appreciate your email and wish you a wonderful day! Best Regards, DJI Innovations SDK Technical Support Team
    0
    Comment actions Permalink
  • a2499908981

    $ sh deleteResource.sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100    91  100    91    0     0    154      0 --:--:-- --:--:-- --:--:--   155{"result":{"code":102001,"msg":"invalid param: query or form param","desc":"InvalidParam"}}

    still error...

    0
    Comment actions Permalink
  • DJI Developer Support
    Dear Developer, Hello and thank you for reaching out to DJI Innovations. Could you send the specific request payload? The payload is an empty string. Please retest according to the attached screenshot We hope that our solution meets your needs satisfactorily. We appreciate your email and wish you a wonderful day! Best Regards, DJI Innovations SDK Technical Support Team
    0
    Comment actions Permalink
  • jabanat

    Please retest according to the attached screenshot

    Could you please share the screenshot?

    0
    Comment actions Permalink
  • a2499908981

    I ran above code, the result is error.


    $ sh deleteResource.sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100    91  100    91    0     0    218      0 --:--:-- --:--:-- --:--:--   218{"result":{"code":102001,"msg":"invalid param: query or form param","desc":"InvalidParam"}}
    0
    Comment actions Permalink
  • a2499908981

    I set the playload below.

    payload=$(

    cat <<EOF

    EOF

    )

    I try to set the playload as an empty string as below.

    payload='' or playload = ""
    0
    Comment actions Permalink
  • a2499908981

    same error

    $ sh deleteResource.sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100    91  100    91    0     0    249      0 --:--:-- --:--:-- --:--:--   251{"result":{"code":102001,"msg":"invalid param: query or form param","desc":"InvalidParam"}}

    I think is not the payload result?

    0
    Comment actions Permalink
  • DJI Developer Support
    Dear Developer, Hello and thank you for reaching out to DJI Innovations. You can test by copying and pasting this part without making any changes. In fact, if there is a `payload` in the code, `payload` represents the body of the method, and what is added is a parameter for the method body. Since the `delete` method does not have a method body, you can simply use `payload=$( cat <
    1
    Comment actions Permalink
  • jabanat

    I think part of your message got cut off. Could you please provide the full code for me to test

    0
    Comment actions Permalink
  • DJI Developer Support
    Dear Developer, Hello and thank you for reaching out to DJI Innovations. Could you please send the latest failed request message so we can take a look? We hope that our solution meets your needs satisfactorily. We appreciate your email and wish you a wonderful day! Best Regards, DJI Innovations SDK Technical Support Team
    0
    Comment actions Permalink
  • a2499908981

    Dear Developer, Hello and thank you for reaching out to DJI Innovations. You can test by copying and pasting this part without making any changes. In fact, if there is a `payload` in the code, `payload` represents the body of the method, and what is added is a parameter for the method body. Since the `delete` method does not have a method body, you can simply use `payload=$( cat <

    according to your words above, I test, but error as below.

    $ sh deleteResource.sh
    deleteResource.sh: line 8: syntax error near unexpected token `newline'
    deleteResource.sh: line 8: `payload=$( cat <<'

    0
    Comment actions Permalink
  • DJI Developer Support
    Dear Developer, Hello and thank you for reaching out to DJI Innovations. The response for this support ticket is based on the packet information provided by the user who initiated it. If you do not use a payload in your shell script, then you should not add it. The suggestion to include a payload is because the initiating user's original packet included a payload, but they did not explicitly set the parameter to an empty value, i.e.: payload=$( cat <
    0
    Comment actions Permalink
  • jabanat

    DJI Developer Support do you have any suggestions?

    0
    Comment actions Permalink
  • DJI Developer Support
    Dear Developer, Hello and thank you for reaching out to DJI Innovations. 1. There may be an issue with the API endpoint. 2. The UUID parameter that is being passed might be incorrect. 3. There could be a problem with the JSON parameters. Please check if the UUID you want to delete can be queried successfully, and ensure that all required parameters are correct and complete. We hope that our solution meets your needs satisfactorily. We appreciate your email and wish you a wonderful day! Best Regards, DJI Innovations SDK Technical Support Team
    0
    Comment actions Permalink
  • jabanat

    I can confirm the UUID parameter is valid as it returns:

    {"data":{"summary":{"uuid":"85910e50-b3e8-414e-b80d-7edd7ef49fae","createdAt":"2024-07-30 08:35:31Z","updatedAt":"2024-07-30 08:35:31Z","name":"Propeller Lidar Test Resource","type":"map","meta":"","fileCount":3,"totalSize":26128283,"scope":{"minLatitude":0,"maxLatitude":0,"minLongitude":0,"maxLongitude":0},"revisable":true,"downloadUsedTime":0,"uploadUsedTime":0,"status":0},"fileUuids":["b2caeb7a-d6ed-417e-bb6c-ee5d1af4b59c","a135459d-7348-4c61-b3d9-e3fa3b78c5d1","797b5ede-12db-4a01-9680-4a8ab2d6fc0b"],"inputJobUuids":[],"outputJobUuids":[]},"result":{"code":0,"msg":"success","desc":"success"}}%   

    I still get the same error when trying to DELETE:

    {"result":{"code":102001,"msg":"invalid param: query or form param","desc":"InvalidParam"}}%                                                                                                  
    0
    Comment actions Permalink
  • nicholas

    Any new updates on this topic? We encounter the same exact error.

    We reproduced every step mentioned in this issue and we experience the exact same behaviour and error.

    0
    Comment actions Permalink
  • nicholas

    Hi jabanat,

    I’ve discovered a solution after some thorough testing and experimentation. Although our query parameters precisely match the documentation, the API was returning an error: "invalid param: query or form param". This led me to suspect that the API validation might require a non-empty body, even for DELETE requests.

    Here’s what I found:

    • Empty Payloads: Sending an empty string as the payload consistently triggers the same error.
    • Non-Empty Payloads: Providing any non-empty payload allows the request to go through successfully.

    Solution: To resolve the issue, ensure that you include a non-empty payload in your DELETE request. For example, instead of leaving the body empty as shown in the documentation, you can include a simple JSON object or any other minimal content required by the API.

    Example:

    payload=$(
    cat <<EOF
    EOF
    )

    Replace with:

    payload="{}"

    By including a non-empty payload, the API should accept your DELETE request without returning the invalid parameter error.

    I hope this helps!

    0
    Comment actions Permalink

Please sign in to leave a comment.