google-cloud-platformcurlcmdarcore

curl in cmd, Error 'Unknown name' (Cloud anchor Management API)


I am trying the Cloud Anchor Management API, but there is an error while using the curl. The list, deletion, etc. all work well, but only commands related to TTL update are not working. I didn't know what tool to use that code, so I was typing it in Windows cmd (Command Prompt) and using it. Do you know where to enter the original command? Or how do I fix the cmd command?

I'm using a translator, so I'm really sorry if my English is weird.

TTL Update original text

export BEARER_TOKEN=`(oauth2l fetch --json creds.json arcore.management)`
curl -H "Authorization: Bearer $BEARER_TOKEN" -H "Content-Type: application/json" -X "PATCH" \
   "https://arcore.googleapis.com/v1beta2/management/anchors/your-anchor-id-here?updateMask=expire_time" \
    -d '{ expireTime: "2021-06-29T21:00:00Z" }'

My command

curl https://arcore.googleapis.com/v1beta2/management/anchors/ua-f5f6649027a6e12dbd16e00fb9563c61?updateMask=expire_time ^
-H "Authorization: Bearer (I input Token here)" ^
-H 'Content-Type: application/json' ^
-X PATCH ^
-d expireTime=2024-07-31T02:00:00Z

I tried to use the original text with a slight modification for use in cmd. If you refer to the picture, you can see the codes that I actually entered. I tried to generate tokens, check the list, and update the TTL. I'm new to cmd commands so I think there's going to be a grammatical error, but I'm not sure. I'm sorry.

My Try Command and Result Image

C:\Users\admin\Downloads\windows_amd64>curl -H "Authorization: Bearer (I input Token here)" ^
More? -H 'Content-Type: application/json' ^
More? -X PATCH ^
More? https://arcore.googleapis.com/v1beta2/management/anchors/ua-f5f6649027a6e12dbd16e00fb9563c61?updateMask=expire_time ^
More? -d expireTime="2024-07-31T02:00:00Z"
curl: (6) Could not resolve host: application
{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"expireTime\": Cannot bind query parameter. Field 'expireTime' could not be found in request message.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "description": "Invalid JSON payload received. Unknown name \"expireTime\": Cannot bind query parameter. Field 'expireTime' could not be found in request message."
          }
        ]
      }
    ]
  }
}

----------------- New Try ----------------

Sorry I'm not good at using stack overflow, thank you so much for your reply! I created a bat file. Actually, I don't know much about this field...

Try : Make "test.bat" file

curl -H "Authorization: Bearer ya29.c.b0Aaekm1KrOFoqfduQgHZGZXw9WjMghqk3pLdgMs3KnNqtgJewZZ8jgyNhRWJT8Sz4sfvNUYM38v8sRPHFHEsqCPWmjMok93ZT-8lctZD4GSZirazMrzc0hkkw5bE0zpBT9T7s-u0Wskf0JmPL-0hzc0BBplNMXf00VXBMUZDk-Bzq5defQi1mZGLvWD8AuLcsrqH-Z09-OBZ8SnjheC-8G5CQURYOqRfuki0xFc3CLjNgtfbYf4mRgNEZaJUaWw2bBYCKQ1QoXU27DtKFN2J4PAy_XtOfZwX5YV6Gx7iC6o-Gq0cgQ-BaybRWnAC_0iZs_jUsI7VeE337Czvz_USc4zOQI_0w2Oac5_dqtgcI1nlt71viIFIvoRbdrfso6bFrhgSQ0o5V7VpuS79IgIBqtca8W2oe97BVb1Fojr2g65kXlqs4Sb73xdy-2n1_v9VXvaz1ks69vxM0Q6m8slajS-cZwfVVsXv38qZBsxatoyk6gSQ0Jlc2B9imonScIZwg5qUMIO5MV4bmRBIIImpta6sM924drqV07MbrsOrfjkiFr_o6j0Vh553t77RMYnBnB2toisXs6xhddvIg5l4bppirsYaQeuv5ZpcJiw2Jpx_Xwmyos70S6SVu1Q_zBmmaFw13d_mfQ1g0vIM6lR39nqhmnpSixIrgBcjQx6nYZS_hYqd_YB-F39bMZFplX67xbZrectI-q4vV0Jajb9d1v9s1dJ1JYx88QiSn5WuwM75yvyn7p-_QJdqm3ik1kJItbeRh_cdahn4xvwuco1ZYSvZoU4Uh7lvV7QuhdbaVd-Oc2RYurM04onRMkUo7xQ1nMuQ-vhSdm--oqWW-dxxor7MWJ4m4jJbOwdFskyiBwx239uliuckbbuVFiO-syV5ro1paQutyUn2myp9bl_YmQJJXOJw72oSgXhUwry7yJZ4ymXtZr6I7Z2hgU7Oi9Bp3t96jpbWQZjhOvglph11zcOq-3mh-RYmxYtFowBmJob2w9uFJkQ17n0M" ^
-H "Content-Type: application/json" ^
-X "PATCH" ^
"https://arcore.googleapis.com/v1beta2/management/anchors/ua-596882ce29fa2acdc395fe6622dbdc23?updateMask=expire_time" ^
-d { expireTime: "2024-08-02T07:00:00Z" }

Result :

`C:\Users\admin\Downloads\windows_amd64>curl -H "Authorization: Bearer ya29.c.b0Aaekm1KrOFoqfduQgHZGZXw9WjMghqk3pLdgMs3KnNqtgJewZZ8jgyNhRWJT8Sz4sfvNUYM38v8sRPHFHEsqCPWmjMok93ZT-8lctZD4GSZirazMrzc0hkkw5bE0zpBT9T7s-u0Wskf0JmPL-0hzc0BBplNMXf00VXBMUZDk-Bzq5defQi1mZGLvWD8AuLcsrqH-Z09-OBZ8SnjheC-8G5CQURYOqRfuki0xFc3CLjNgtfbYf4mRgNEZaJUaWw2bBYCKQ1QoXU27DtKFN2J4PAy_XtOfZwX5YV6Gx7iC6o-Gq0cgQ-BaybRWnAC_0iZs_jUsI7VeE337Czvz_USc4zOQI_0w2Oac5_dqtgcI1nlt71viIFIvoRbdrfso6bFrhgSQ0o5V7VpuS79IgIBqtca8W2oe97BVb1Fojr2g65kXlqs4Sb73xdy-2n1_v9VXvaz1ks69vxM0Q6m8slajS-cZwfVVsXv38qZBsxatoyk6gSQ0Jlc2B9imonScIZwg5qUMIO5MV4bmRBIIImpta6sM924drqV07MbrsOrfjkiFr_o6j0Vh553t77RMYnBnB2toisXs6xhddvIg5l4bppirsYaQeuv5ZpcJiw2Jpx_Xwmyos70S6SVu1Q_zBmmaFw13d_mfQ1g0vIM6lR39nqhmnpSixIrgBcjQx6nYZS_hYqd_YB-F39bMZFplX67xbZrectI-q4vV0Jajb9d1v9s1dJ1JYx88QiSn5WuwM75yvyn7p-_QJdqm3ik1kJItbeRh_cdahn4xvwuco1ZYSvZoU4Uh7lvV7QuhdbaVd-Oc2RYurM04onRMkUo7xQ1nMuQ-vhSdm--oqWW-dxxor7MWJ4m4jJbOwdFskyiBwx239uliuckbbuVFiO-syV5ro1paQutyUn2myp9bl_YmQJJXOJw72oSgXhUwry7yJZ4ymXtZr6I7Z2hgU7Oi9Bp3t96jpbWQZjhOvglph11zcOq-3mh-RYmxYtFowBmJob2w9uFJkQ17n0M" ^
-H "Content-Type: application/json" ^
-X "PATCH" ^
"https://arcore.googleapis.com/v1beta2/management/anchors/ua-596882ce29fa2acdc395fe6622dbdc23?updateMask=expire_time" ^
-d { expireTime: "2024-08-02T07:00:00Z" }'
{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Closing quote expected in string.\n\n^",
    "status": "INVALID_ARGUMENT"
  }
}
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched close brace/bracket in URL position 1:
}'
 ^

C:\Users\admin\Downloads\windows_amd64>pause
Press any key to continue . . . `

It's a token I just made, so I might be able to try it yourself for an hour or so! I really want to work this out..


Solution

  • I'm not familiar with Cloud Anchor Management API, but it seems that you were trying to send an invalid json request body. Actually, it's quite hard to use curl to send HTTP request for beginners(due to content encoding or other problems), I highly recommend you to use some GUI HTTP client like postman or insomnia in dev or API research stage, instead of using command line tools like curl, in most cases, curl need to do some escape to request body.