DJI TerraAPI "DELETE"
已完成Hello. I'm having trouble with the DELETE calls to the API, specifically for the `Resource` and `Files` endpoints.
My script looks like:
#!/bin/bash
DJI_APP_KEY=""
DJI_SECRET_KEY=""
URI="/terra-rescon-be/v2/resources/153bdcf3-0d66-412b-bdfd-b10aeea098ed"
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'
The response is:
{"result":{"code":102001,"msg":"invalid param: query or form param","desc":"InvalidParam"}}
URI="/terra-rescon-be/v2/resources/153bdcf3-0d66-412b-bdfd-b10aeea098ed?
deleteMode=0"
I get the same response:
{"result":{"code":102001,"msg":"invalid param: query or form param","desc":"InvalidParam"}}
#!/bin/bash
DJI_APP_KEY=""
DJI_SECRET_KEY=""
URI="/terra-rescon-be/v2/resources/153bdcf3-0d66-412b-bdfd-b10aeea098ed"
HTTP_METHOD=GET
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'
{"data":{"summary":{"uuid":"153bdcf3-0d66-412b-bdfd-b10aeea098ed","createdAt":"2024-07-30 08:42:39Z","updatedAt":"2024-07-30 08:42:39Z","name":"Propeller Lidar Test Resource","type":"map","meta":"","fileCount":0,"totalSize":0,"scope":{"minLatitude":0,"maxLatitude":0,"minLongitude":0,"maxLongitude":0},"revisable":true,"downloadUsedTime":0,"uploadUsedTime":0,"status":0},"fileUuids":[],"inputJobUuids":[],"outputJobUuids":[]},"result":{"code":0,"msg":"success","desc":"success"}}
-
Thanks for your quick response! Unfortunately I am still getting the same response:
#!/bin/bash
The curl verbose response is:
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* 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"}}% -
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 -
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"}} -
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?
-
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 < -
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 -
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 <<' -
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 < -
DJI Developer Support do you have any suggestions?
-
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 -
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"}}%
请先登录再写评论。
评论
18 条评论