cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

I am getting invalid_url again and again with /save_url, https://api.dropboxapi.com/2/files/save_url

I am getting invalid_url again and again with /save_url, https://api.dropboxapi.com/2/files/save_url

ABDUL Salam
Explorer | Level 3

Hi,
I have an app that uses https://api.dropboxapi.com/2/files/save_url/save_url  endpoint to save urls from my ecommerce store to my dropbox. It was working fine early on locally bu as soon as I have deployed my script and check the logs after execution then this endpoint returns me a async_job_id which I use to check job status from https://api.dropboxapi.com/2/files/save_url/check_job_status and I get

{
".tag": "failed",
"failed": {
".tag": "invalid_url"
}
}
this error as response again and again.
I am using PHP as development language and curl for making requests to /save_url endpoint.
Although I am sure my URL's are not invalid.

 

 

 

 

 

function saveCustomilyOrders($dropboxURL, $accessToken, $customilyOrders)
{
    $apiURL = $dropboxURL . '/2/files/save_url';
    $headers = [
        'Authorization: Bearer ' . $accessToken,
        'Content-Type: application/json',
    ];
    foreach ($customilyOrders as $customilyOrder) {
        $path = $customilyOrder['path'];
        $url = $customilyOrder['url'];
        $payload = [
            'path' => $path,
            'url' => $url,
        ];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $apiURL);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        if ($httpCode == 200) {
//Do some logs
        } elseif ($httpCode != 200) {
            throw new Exception('something went wrong while saving customily orders to dropbox: ' . $httpCode . ' ' . $response);
        }
        sleep(5);
    }
}

 

 

 

 

 

this is the snippet of function which I am using to /save_url enpoint.
Any suggestion in this issue will be highly appreciated as this is getting so much annyoying that it sometimes works and some times not and now its giving invalid_url again and again.
my json_encoded body looks like this in my curl request:
"{"path":"\/2023\/November\/#1123\/GP\/#1123_GK.eps","url":"https:\/\/cdn.customily.com\/ExportFile\/pf-dev-3\/b462fef1-aff5-42fa-aa77-f4eb0a6c7cce.eps"}" 
@Greg-DB 
if you can look into this.
Thanks.

16 Replies 16

ABDUL Salam
Explorer | Level 3

@Greg-DB @ЗГравко  

 

Listening on 0.0.0.0 8080
Connection received on DN-12 57
POST /2/files/save_url HTTP/1.1
Host: MY_IP:8080
Accept: */*
Authorization: Bearer sl.<tokenhere>
Content-Type: application/json
Content-Length: 174

{"path":"/2023/November/#1138/GOLF-P-WE-AU-BLACK/#1138_GOLF-P-WE-AU-BLACK.eps","url":"https://cdn.customily.com/ExportFile/pf-dev-3/a79b3bc0-80a1-4e48-aae7-eab0edd4b54d.eps"}

 

this is what I got after running netcat on my local machine and redirecting queries to my local system.

Greg-DB
Dropbox Staff

@ABDUL Salam Thanks for sharing that. I just tried plugging in those exact values, and the file saved successfully for me. Are you still seeing this issue if you try those exact values?

ABDUL Salam
Explorer | Level 3

@Greg-DB

The issue arises when I execute my script as a cron task on my hosting platform. This script performs the following tasks:

  1. Retrieves orders from an ecommerce store.
  2. Processes the received data to refine its format.
  3. Searches for a specific URL attribute within each order and stores it in an array if found.
  4. Subsequently, it initiates a call to the Dropbox API to acquire an access_token. This token is obtained using a previously stored refresh token. Following this, it invokes the '/save_url' endpoint.
  5. All operational information is logged in a dedicated file, signifying the successful completion of each step. However, upon calling the '/save_url' endpoint, an 'async_job_id' is returned.
  6. Using this 'async_job_id' for verification purposes consistently results in an 'invalid URL' error. Interestingly, the same URL functions correctly when hardcoded in /save_url request parameter.




 
 

ЗГравко
Legendary | Level 20

The same like in Greg's experiment, everything works as expected.

 


@ABDUL Salam wrote:

... It was working fine early on locally bu as soon as I have deployed my script and check the logs after execution then this endpoint returns me a async_job_id which I use to check job status from https://api.dropboxapi.com/2/files/save_url/check_job_status and I get ...


@ABDUL Salam, In this context, do you redirect your call from local machine or from the place where you are trying to deploy your script (where it fails actually)? If you do it locally only,... :slightly_smiling_face:

ЗГравко
Legendary | Level 20

@ABDUL Salam wrote:

... Interestingly, the same URL functions correctly when hardcoded in /save_url request parameter.


Do it in the same way when the request fails, not like when succeeds!

ABDUL Salam
Explorer | Level 3

@Greg-DB Is there any way we can check what URL/OR params were passed to the job so that from its  async_job_id we can see it in response? This currently generically gives a failed tag with invalid_url. 
https://api.dropboxapi.com/2/files/save_url/check_job_status

{
".tag": "failed",
"failed": {
".tag": "invalid_url"
}
}

 

Greg-DB
Dropbox Staff

@ABDUL Salam The Dropbox API does not offer a way to echo back the parameters/URL sent to /2/files/save_url.

 

As ЗГравко asked though, were you inspecting this in the actual environment where this is failing?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    ABDUL Salam Explorer | Level 3
  • User avatar
    ЗГравко Legendary | Level 20
What do Dropbox user levels mean?