문제

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>..."

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top