Can't get basic example to work :(

Hi all, tried several ways but can pass the basic step of uploading a video. Always get the result bellow:
{ “result”: null, “success”: false, “errors”: [ { “code”: 10004, “message”: “Decoding Error” } ],
“messages”: null}

  1. Per doc ‘get started’
    curl -X POST -d ‘{“url”:“http://techslides.com/demos/sample-videos/small.mp4",“meta”:{“name”:"small.mp4”}}’ ^
    -H “Authorization: Bearer n######################################e” ^
    https://api.cloudflare.com/client/v4/accounts/1##############################9/stream/copy
  2. As per API doc
    curl -X POST “https://api.cloudflare.com/client/v4/accounts/1##############################9/stream/copy” ^
    -H “X-Auth-Email: fabrice####@######.###” ^
    -H “X-Auth-Key: 5###################################8” ^
    -H “Content-Type: application/json” ^
    –data ‘{“url”:“http://techslides.com/demos/sample-videos/small.mp4",“meta”:{“name”:"small.mp4”}}’
  3. As per form in account
    curl -X POST ^
    -d ‘{“url”:“http://techslides.com/demos/sample-videos/small.mp4",“meta”:{“name”:"small.mp4”}}’ ^
    -H “X-Auth-Key: 5###################################8” ^
    -H “X-Auth-Email: fabrice####@######.###” ^
    https://api.cloudflare.com/client/v4/accounts/1##############################9/stream/copy

Of course, I use the real token, api key, email, not obfuscated as here :slight_smile:
And the ^ are just for multiline in WT (as \ in linux). Even tried as one-line, same result :wink:
Anyone as a clue what is wrong here please?
Have a nice day.

“Decoding error” usually means that you’re submitting invalid JSON in the HTTP request body. In the examples you’ve posted above, I see that you’re using “smart quotes”, which are not supported in JSON.

I wonder if you tried submitting the same request with normal quotes.

Hi Renan. Thanks for your input. I am using valid RFC 8259 JSON with machine quotes. When I past the code into the post here it gets modified by the forum script, but the original is with machine quotes.


becomes ‘"{“url”:"http://techslides.com/demos/sample-videos/small.mp4",“meta”:{“name”:“small.mp4”}}"’ on the post.

I got the solution, it may help someone. After the -d parameter, the json should be enclosed within double quotes (not single as per doc) and the json itself should be escaped (double quotes escaped with a backslash).

curl -X POST ^
-d "{\“url\”:\"http://techslides.com/demos/sample-videos/small.mp4\",\“meta\”:{\“name\”:\“small.mp4\”}}" ^
-H “X-Auth-Key: 5###################################8” ^
-H “X-Auth-Email: fabrice###@######.###” ^
https://api.cloudflare.com/client/v4/accounts/1##############################9/stream/copy

This for curl on a window terminal.