Jump to content
  • 0

Post/Put File Using API and C#



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

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...