Forum Discussion

luofeiyu's avatar
luofeiyu
New member | Level 2
7 years ago

Could not resolve host: content.dropboxapi.com when to upload file at shutdown

I want to upload file into my dropbox when my pc is shutdowning.
sudo vim  /etc/systemd/system/upload.service
[Unit]
Description=upload files into dropbox
Before=network.target shutdown.target  reboot.target
Requires=network-online.target

[Service]
ExecStop=/bin/true
ExecStart=/bin/bash  /home/upload.sh 
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
And the upload.sh script.
cd  /home
curl -X POST https://content.dropboxapi.com/2/files/upload \
            --header "Authorization: Bearer xxxx" \
            --header "Dropbox-API-Arg:  {\"path\":\"/test.txt\",\"mode\":{\".tag\":\"overwrite\"}}" \
            --header "Content-Type: application/octet-stream" \
            --data-binary @"test.txt"
`bash upload.sh` can executed successfully,and file uploaded into my dropbox.
sudo systemctl enable upload service  
To reboot my pc.
sudo journalctl -u upload 
Apr 13 23:58:52 localhost systemd[1]: Started upload files into dropbox.
Apr 13 23:58:52 localhost systemd[1]: Starting upload files into dropbox...
Apr 13 23:58:52 localhost bash[117]: % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Apr 13 23:58:52 localhost bash[117]: Dload  Upload   Total   Spent    Left  Speed
Apr 13 23:58:52 localhost bash[117]: 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: content.dropboxapi.com; Un
Apr 13 23:58:52 localhost systemd[1]: upload.service: main process exited, code=exited, status=6/NOTCONFIGURED
Apr 13 23:58:52 localhost systemd[1]: Unit upload.service entered failed state.
Apr 13 23:58:52 localhost systemd[1]: upload.service failed.
How to solve the issue when to upload file into dropbox at shutdown?
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff
    Based on the error message you posted, this is failing because your machine was unable to look up the 'content.dropboxapi.com' host. That's the correct hostname, and it is resolving correctly for me.

    That being the case it appears to be an issue with your DNS server, which is out of our control. Please check on your DNS server to see why it is not returning a result for content.dropboxapi.com.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,945 PostsLatest Activity: 2 hours ago
351 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!