FoxPro Programming
Post a File
Gravatar is a globally recognized avatar based on your email address. Post a File
  Richard Caruso
  Oct 5, 2020 @ 11:45am

We are trying to post a file using wwHTTP. Was wondering if we could be pointed in the right direction. We are new to CURL and Posting Files.

Here is the sample CURL command client gave us to use. We need to capture the return code to make sure the file was uploaded successfully (code 200):

curl -X POST 
--data-binary "@G:\Curl\LU0123_09302020.txt" 
-H "Appian-API-Key: eyJ0eXAiOiJKV1QiLCJhbG....sample key" 
-H "Appian-Document-Name: LU0123.txt" -H "Local: 123" -H "Month: 9" -H "Year: 2020" -H "Overwrite: N"

Our VFP Code using code samples:


loHttp.AddPostKey(" --data-binary @G:\Curl\LU0190_09302020.txt")
loHttp.AddPostKey("Appian-API-Key: ","eyJ0eXAiOiJKV1QiLCJhbG....sample key")
loHttp.AddPostKey("Appian-Document-Name: ","LU0190_09302020.txt")
loHttp.AddPostKey("Local: ","123")
loHttp.AddPostKey("Month: ","9")
loHttp.AddPostKey("Year: ","2020")
loHttp.AddPostKey("Overwrite: ","N")


* We've tried a variation of calls with the same error result (sample cURL)
lcText = loHttp.HTTPGet("")
lcText = loHttp.Post("")
Error = "{"resource":"\/suite\/webapi\/per-capita-file","error":"APNX-1-4187-000","message":"Authentication failed. Please check your credentials and try again.","title":"An Error Has Occurred"}"

Thanks in advance,


Gravatar is a globally recognized avatar based on your email address. re: Post a File
  Rick Strahl
  Richard Caruso
  Oct 5, 2020 @ 09:37pm

All those values are headers according to the curl command, not post buffer values. Try using .AddHeader() instead of .AddPostKey().

The post buffer looks like it expects a file to be uploaded which probably is just the content of the file. Hard to say whether the file is expected to be an HTTP form upload or just the raw data buffer. I would guess the latter:


+++ Rick ---

© 1996-2020