Can someone explain what I'm doing wrong here? I'm specifying the length header. No idea why its saying "Length Required". This request works fine when I send it through Postman, but fails when I send it through Flurl in C#. Heres the API docs for the call.
Error uploading attachment: Flurl.Http.FlurlHttpException: POST https://xxx.leankit.com/kanban/api/card/SaveAttachment/365784226/733054060 failed with status code 411 (Length Required).\r\nResponse body: Bad Request \nYour browser sent a request that this server could not understand.
Upload File code
public static async Task<string> UploadFile(string externalcardid, string filePath,string filename,int boardId,long size)
{
try
{
var url = "https://xxx.leankit.com/kanban/api/card/SaveAttachment/" + boardId + "/" + externalcardid.ToString();
var responseString = await url.WithBasicAuth("xxx", "yyy")
.WithHeader("Content-Length", size)
.WithHeader("Content-Type", "multipart/form-data")
.PostMultipartAsync(mp=> mp
.AddFile(filename,filePath)
)
.ReceiveString();
return (responseString);
}
catch (Exception e)
{
return ("Error uploading attachment: " + e);
}
}