Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

CURL request to attach a file fails - curl: (26) read function returned funny value

atalwar November 2, 2021

Hi Team,

 

I'm trying to upload a file to a confluence using the following curl. 

 

script {
response = sh(script: "curl -u 'xxxxx@xxxxxx:xxxxxxxxxx' -X POST -H 'X-Atlassian-Token: no-check' -F 'file=@${workspace}/1.txt' https://xxxxx.xxxxxx/wiki/rest/api/content/xxxxxx/child/attachment", returnStdout: true)
echo '=========================Response===================' + response
}

 

The file is placed in the Downloads directory on my laptop. I have changed the permission to 777, so accessing it shouldn't be a problem. However, the curl request seems to fail.

curl: (26) read function returned funny value


ERROR: script returned exit code 26

 

1 answer

0 votes
Thomas Deiler
Community Champion
November 3, 2021

Dear @atalwar ,

have you tried, for debugging, to replace ${workspace} with a hard-coded path?

 

BtW: The endpoint 

https://xxxxx.xxxxxx/wiki/rest/api/content/xxxxxx/child/attachment

doesn't look like to fit for cloud (you tagged the question as 'cloud'). It should be

https://<name>.atlassian.net/rest/api/content/{id}/child/attachment

So long

Thomas

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events