Looking for help with Form Data Body API example

Have an API that can be used to attach files (into ClickUp) and trying to implement into my EPF code. Trying with the basics I ended up using POSTMAN and got it to work but unable to duplicate it in EPF. I am 99% sure its the formdata part I am not getting the format or details right

In POSTMAN I wish Sensetalk was in there for a code snippet but it is not. I am showing the CURL snippet but not sure if this is of any help

The documentation from ClickUp isnt helping me much
https://www.postman.com/clickup-api/clickup-public-api/request/uch46ml/create-task-attachment?tab=overview

I know this isn’t right but in short showing what I have been trying to do

Was able to do outside and API script using the post multipart command. I might still play with moving this to an API script if anyone has ideas on how this might copy over?
image

1 Like

Hello,

To upload a file to ClickUp via EPF (SenseTalk), structure a multipart/form-data POST with headers and file content like this:

put “your_api_key” into apiKey
put “your_task_id” into taskID
put “C:/Path/To/Your/File.txt” into filePath

put “–boundary123” & return into body
put ‘Content-Disposition: form-data; name=“attachment”; filename="’ & filePath’s short name & ‘"’ & return into body
put “Content-Type: application/octet-stream” & return & return into body
put file filePath into fileContents
put body & fileContents & return & “–boundary123–” & return into body

put [
method:“POST”,
headers:[
“Authorization”: apiKey,
“Content-Type”: “multipart/form-data; boundary=boundary123”
],
body:body
] into request

put post & taskID & “/attachment” with request into result
put result.

File path is correct

Boundary matches in body and header

File is read correctly

Best Regard,
Helen

Hey @GTPWilks,

here is a version I have used in the past next to the multipart (which is much simpler from my perspective).


set user to "admin"
set id to "123"
set myheader to {
	"name":"id",
	"contents":id
}
set myBody to {
	name:"id",
	contents:user
}


set myURL to "https://postman-echo.com/post"
put APostRequest(httpmethod:"POST",Url:myURL,requestbody:myBody, requestheaders:myHeaders) into ApiResults

log jsonformat(ApiREsults) 

Hey @Karsten,
i am trying to post a zip file using below code, this doesn’t work.
My Code:

* Post multipart {fieldName:"attachment",filename:fileNameForUpload,Body: zipFilePath} to URL MyURL with headers headers1

Headers:

put {
	"Authorization": "Basic " & encodedCredentials,
	"X-Atlassian-Token": "no-check"
} into headers1

I also tried this code, but no luck
put APostRequest(httpmethod:"POST",Url:myURL,requestbody:myBody, requestheaders:myHeaders) into ApiResults

Hey @liki7411 ,

Post multipart {fieldName:"attachment",\
			filename:fileNameForUpload,\
			Body: file zipFilePath as data} \
		to URL MyURL with headers headers1

See above. Can you add file before your variable zipFilePath and afterwards as data

here is the docu URL Transactions and Formatting | EPF Docs

1 Like

@Karsten yes i have tried that as well , post multipart {fieldName:"attachment",filename:fileNameForUpload,Body: file zipFilePath as data} to URL jiraURL with headers headers1 . I get blank response for this too. I checked file size which is - 761113 bytes

Hey @liki7411 ,

  1. Does it work with a non zip file? txt, png? Can you try ?
  2. Can you share the Jira documentation, API endpoints and describe a bit more what you want to achieve?
  3. Do you know which Technical Consultant is assigned to your account? Can you reach out to her/him directly to support handson in a webmeeting.
  4. Did you verify its working via Postman or curl on cmd/terminal?
  5. Can you share the full scripts and add placeholders for credentials and your Jira URL ?
    Cheers,
    Karsten
1 Like