Has anyone been able to issue a post or put operation for a file insert/update using the Caspio API? I keep getting a 400 error? I was getting an authorization error, but I fixed that and I'm now stuck on the Bad Request error.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
ForeGolfer
Has anyone been able to issue a post or put operation for a file insert/update using the Caspio API? I keep getting a 400 error? I was getting an authorization error, but I fixed that and I'm now stuck on the Bad Request error.
Below is my code:
String url = "https://<myAcctId.>caspio.com/rest/v2/files";
String filePath = "\\\\fileserver\\DEV\\2023\\Case\8222_APPR_2312300915129474.pdf";
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("accept", "application/json");
request.Headers.Add("Authorization", auth);
MultipartFormDataContent content = new MultipartFormDataContent();
content.Add(new ByteArrayContent(File.ReadAllBytes(filePath)), "File", Path.GetFileName(filePath));
request.Content = content;
request.Content.Headers.ContentType = new MediaTypeHeaderValue("multipart/form-data");
response = await client.SendAsync(request);
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.