How can I download a (v2 API) report using curl?

I can use the v2 API to start a report, wait until it is finished, and get a link to the report, all using curl.

But when I try to download the report from the link using curl, curl says:

curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535

(I’m not sure the problem is really the port number (since there isn’t one in the link that I can find – there are no colons other than the one in “https:”) but the curl man page says a code of 3 means “URL malformed. The syntax was not correct.”)

Here’s the curl command I use in a shell script:

        curl --no-progress-meter \
             -X GET $download_link \
              > /tmp/curl_stdout 2> /tmp/curl_stderr

If I paste the link into Safari, the returned document is XML, and starts with:

<Error>
  <Code>SignatureDoesNotMatch</Code>
  <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

The link itself looks like this:

https://crowdin-tmp.downloads.crowdin.com/*****/top-members/*****.csv?response-content-disposition=attachment%3B%20filename%3D%22Tunnelblick.top-members.words.af.report.csv%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=*****%2F20231123%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231123T034827Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=*****

(The first ******** is an 8-digit integer, the second ***** is a 34-character UUID, the third ***** is a 20-character code of some sort, and the last ***** is 64 hex characters.

Any suggestions?

Hello @Tunnelblick

Can you share the link to your project so I can review the API logs via my database?

Also, if you try to use the same request via some API client or a sandbox tool (for example Postman) will the result be the same? Can you kindly check it?

Meanwhile, I’ll do few tests from my side in order to re-produce your issue with curl and provide some solution on the matter.

Thanks for your quick response, @Dima .

The project is at Crowdin

One further comment: The API returns a string that backslash-encodes forward slashes, e.g. the “https://” appears in the string as “https:\/\/”. I have removed those for testing with Safari. I think they are removed by the time they get to the curl command that attempts to download them, but I will check that and reply here.

Hi @Tunnelblick , sure, you’re welcome to re-check and update us

Thanks, and I apologize for bothering you. It was my error.

My shell script that invokes curl from the results of the “get download link” API doesn’t work, but when I use the link manually in a terminal window it works fine.

So there’s something wrong with my shell-fu; nothing to do with Crowdin.

The problem was indeed that my shell script did not un-escape the backslash-escaped forward slashes in the download link. If the script un-escapes the link, it works fine.

Dear @Tunnelblick thank you for the update!

Have a nice day :blush: