I'm attempting to attach a file to a comment in a message with the Basecamp API. According to the documentation, I first upload the file as so:
curl -H 'Accept: application/xml' -H 'Content-Type: application/octet-stream' -u 123456789:X -X POST -d @/my/path/test.txt https://myurl.com/upload
This returns an id, so I know the file was uploaded. I then try to attach this file to a comment in a message:
curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u 123456789:X -X POST -d '<comment><body>This is a test</body><attachments><name>blah</name><file><file>$id</file><content-type>application/text</content-type><original-filename>test.txt</original-filename></file></attachments></comment>' https://myurl/posts/987654321/comments.xml
The comment is uploaded however the attachment is not. Does anyone know why the attachment would not be uploaded?
Thanks
I'm not sure if it's your only problem, but the value of
$id
isn't interpolated when you use single quotes, and so you're passing the string'$id'
instead of the value of$id
.Either use
'...<file>'$id'</file>...'
or"...<file>$id</file>..."