Uploading file to a wiki page using curl with the Rest API
Added by Dominic Barker about 7 years ago
Hi All,
I am try to upload an image to a wiki page using the curl. I use the following the following code to receive a tag:
curl --data-binary "@Methodone_error.png" -H "Content-Type: application/octet-stream" -X POST -u username:password https://cdcvs.fnal.gov/redmine/uploads.xml
After I receive the tag I place it into an xml file like so:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<wiki_page>
<title>DomsTestPage</title>
<text>
test !Methodone_error.png! methodone This is a wiki page with images (like this:), and other files. TEST
</text>
<uploads type="array">
<upload>
<token>44630.dbf63796c55340857a9d31f9304420e9</token>
<filename>Methodone_error.png</filename>
<description>An optional description here</description>
<content_type>image/png</content_type>
</upload>
</uploads>
</wiki_page>
I then edit the wiki page like so:
curl -v -u username:password -H "Content-Type: application/xml" -X PUT https://cdcvs.fnal.gov/redmine/projects/sbndcode/wiki/DomsTestPage.xml --data-binary "@DomsTestPage.xml"
This is updating the wiki page but the image has not been loaded. What am I doing wrong! :( What am I missing? Why does the image not get uploaded. Any help would really appreciated .
Cheers
Dom
Replies (1)
RE: Uploading file to a wiki page using curl with the Rest API - Added by Aaron Dasani over 5 years ago
Hey Dominic,
Were you able to find the answer for this problem. Because I have the same problem when i am doing it is JavaScript.
Any help would be appreciated. This is my script.
ApiSnippet.js (1.6 KB) ApiSnippet.js |