I want to use confluence rest api to upload my picture.
I read from [here](https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples)
Use
curl -v -S -u User:User -H 'X-Atlassian-Token: no-check' -F 'file=@/c/Users/User/a.jpg' -F 'comment=test' http://test.atlassian.net/wiki/display/API/upload | python -mjson.tool
But got the error message
* timeout on name lookup is not supported * Trying 165.254.227.xxx... * TCP_NODELAY set % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to eastek-ezcam.atlassian.net (165.254.227.242) port 80 (#0) * Server auth using Basic with user 'User' > POST /wiki/display/API/upload HTTP/1.1 > Host: test.atlassian.net > Authorization: Basic ZWFzdGVrX2NsYWlyZTplYXN0ZWtfY2xhaXJl > User-Agent: curl/7.51.0 > Accept: */* > X-Atlassian-Token: no-check > Content-Length: 119370 > Expect: 100-continue > Content-Type: multipart/form-data; boundary=------------------------d3c715dd14df444a > < HTTP/1.1 301 Moved Permanently < Server: nginx < Date: Mon, 17 Apr 2017 02:49:56 GMT < Content-Type: text/html < Content-Length: 178 < Connection: keep-alive < Location: https://test.atlassian.net/wiki/display/API/upload * HTTP error before end of send, stop sending < { [178 bytes data] 0 116k 100 178 0 0 335 0 --:--:-- --:--:-- --:--:-- 379* Curl_http_done: called premature == 0 0 116k 100 178 0 0 335 0 --:--:-- --:--:-- --:--:-- 379 * Closing connection 0 No JSON object could be decoded
I also try this
curl -T "C:\Users\User\Desktop\a.jpg" "https://test.atlassian.net/wiki/display/API/upload"
and got
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 25982 0 0 100 25982 0 24465 0:00:01 0:00:01 --:--:-- 24465
But the web (https://test.atlassian.net/wiki/display/API/upload) doesn't have the picture I uploaded..
I also try
curl -D- -u User:User -X POST -H "X-Atlassian-Token: nocheck" -F "file=@a.jpg" http://test.atlassian.net/rest/api/content/52408007/child/attachment
and got
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/1.1 301 Moved Permanently Server: nginx Date: Mon, 17 Apr 2017 09:39:40 GMT Content-Type: text/html Content-Length: 178 Connection: keep-alive Location: https://test.atlassian.net/rest/api/content/52408007/child/attachment 0 116k 100 178 0 0 392 0 --:--:-- --:--:-- --:--:-- 406<html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx</center> </body> </html>
What's worng in my code?
Hi! It seems that your load balancer is configured to use https only. So every time you make a "http://xxx" request, the load balancer redirects you to "https://xxx". Can you please try to use https:// urls instead (for example https://test.atlassian.net/wiki/display/API/upload instead of http://test.atlassian.net/wiki/display/API/upload)? Or you may use "follow redirects" curl option
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much, Maksym!!! I think your post is the only place on the internet that actually answers this question! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.