According to the API documentation all I need to supply is a value for "minorEdit" and "file" with a filepath, but even if I provide no body at all I get the same error "...BadRequestException: At least one attachment file must be included". I wondered if maybe it needs the ACTUAL file not just the path so I tried including content type and base64 encoded text of my image. Also wondered why the documentation says "relative file path"... relative to what? But I'm thinking it's failing before that point altogether: I don't think I'm constructing the body content correctly: does this LOOK correct?
--IMabOUnDArY
Content-Disposition: form-data; name="minorEdit"
"true"
--IMabOUnDArY
Content-Disposition: form-data; name="file"
"C:\Users\me\ParsedHTML\Input\Files\DiagramSMK-191453.jpg"
--IMabOUnDArY--
Or I found this post Solved: Uploading attachment into Confluence (atlassian.com) which seems to include the actual file content in the post (although it doesn't mention that on the API documentation, that seems more logical?) but that doesn't work either? Should I try different characters for carriage return new line perhaps?
OK got it working in the end.
Top tips:
------IMabOUnDdfdfAaAAAA
Content-Disposition: form-data; name="file" ; filename="hmmmm.jpg"
Content-Type: image/jpg
Pz8/Pz9BAUFBAD8/YD8/Xn4/fj8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz80204/Pz8/Pz...[etc]
Was using VBA (one off migration task) hence the need for manually constructing the body (using MSXML2.XMLHTTP60). This is why postman is nice: it's a lot easier to use these days I found too. Just setup auth = "API Key" and put Key = "Authorization" and Value = "Basic [and your base64 encoded username:api-key you got from your Atlassian profile]". Click the little </> icon on the right to view the code snippets: select the "HTTP" one to kinda see the raw info that you can mimic for VBA. Took me 10 minutes to get working in postman and a full day to get working in VBA lol. Hope this helps someone!
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.