I am having an issue to use CFHTTP to upload a pdf...
# adobe
s
I am having an issue to use CFHTTP to upload a pdf file. I kept getting error and could not figure out. thanks for the help. here is the response message: {"Value":null,"Status":1,"Message":"An error occurred while attempting to save the attachment."} Header HTTP/1.1 200 OK Cache-Control: max-age=0,no-cache,no-store,post-check=0,pre-check=0 Content-Type: application/json; charset=utf-8 Expires: Mon, 26 Jul 1997 050000 GMT Vary: Content-Encoding Server: Microsoft-IIS/10.0 Set-Cookie: stl=1gy2ipo2jfdlbwxg40tgmthr; path=/; HttpOnly; SameSite=Lax X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Frame-Options: sameorigin Date: Tue, 22 Aug 2023 172851 GMT
p
Please share the code being used, Also it appears nothing is being passed per that response with the value being null.
s
Copy code
Thanks Patrick for the help. here is code: <cfscript>
documentsData={
	file="SPECSHEET-dept-phone-list-phone-list.pdf ",
	filename="SPECSHEET-dept-phone-list-phone-list.pdf ",
	caobjectId ='74972'

};
siteUrl="<https://instage.stlouis.gov/cityworks>";

pllDirectory = "E:\";

endUrl='#siteUrl#/Add?token=#token#&data=#serializeJSON(documentsData)#';
		fileuploaded=#pllDirectory#&#documentsData.file#;
		Cfhttp(URL="#endUrl#", method="POST", multipart="yes", result="apiResponse")
		   {	
				cfhttpparam(type="header", name="Access-Control-Allow-Origin", value="*");
				cfhttpparam(type="header", name="Access-Control-Allow-Methods", value="POST, GET, OPTIONS, PUT");
				cfhttpparam(type="header",name="file",value="#documentsData.file#");
				cfhttpparam(type="FormField", name="Filename", value="#documentsData.file#");
				cfhttpparam(type="File", name="#documentsData.file#",  file="#fileuploaded#");
				
		   }
		cfdump(var="#documentsData#");
		cfdump(var="#apiResponse#");
</cfscript>