httpClient

Hi all,

I’m struggling with an API call to use Put to attach a file to a Confluence page. I can perform the task successfully in Postman, but I am struggling with the httpClient in UiPath.

This is how it looks in Curl:

curl -X PUT \
https://ACMECLIENT.atlassian.net/wiki/rest/api/content/382632184/child/attachment \
  -H 'Accept: */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Authorization: Basic am9obi5tY2ludHlyZUBp' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 78417' \
  -H 'Content-Type: multipart/form-data; boundary=--------------------------562098307277662912467153' \
  -H 'Host: investorsinpeople.atlassian.net' \
  -H 'Postman-Token: 34-6dd0a85a81c4,9659abf6-22b9-4a13-b2dd-2a5297df43a2' \
  -H 'User-Agent: PostmanRuntime/7.20.1' \
  -H 'X-Atlassian-Token: nocheck' \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'file=@/C:/Users/john/Documents/ACMEClient/Timelines/Database encryption.png' \
  -F minorEdit=true \
  -F 'comment=Example attachment comment'

Whenever I try building it out in the httpClient, I receive an error after adding the attachment: “There is already a parameter named Database encryption.png”
This error is mentioned in the documentation, but it is with respect to parameters rather than attachements, and the guidance on how to deal with it is unclear. I am not sure what should be placed in the body text to add the attachent successfully. I am trying -F “file=@/C:/filepath/filename.png” but this does not seem to work as the server returns a 400 error: “At least one attachment file must be included”.
Does anyone have any suggestions? I’m a little bit stumped.

Thanks,

John

Here is a simpler version of the CURL without all the additional bits that postmaster added:

`url -X PUT --url https://ACMEClient.atlassian.net/wiki/rest/api/content/382632184/child/attachment -u username:password -H X-Atlassian-Token:no-check -F file=@C:\Users\john\Documents\ACMEClient\Timelines\Database_encryption.png -F minorEdit=true -F comment=updated_20191127``

Hopefully this is a little clearer! :grinning:

Hello John,
If you want to upload on file on Confluence you have 2 options:
A: via component, you have the video here how to do this:


B: via rest API direct commands in this video:

Thanks,
Cristian Negulescu

Thanks Christian! Here’s the solution that I came up with at the time: https://www.youtube.com/watch?v=yVjux2u6jN0
I have used your component a couple of times since then as it saves a lot of time compared with working out the direct API commands each time!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.