PostFileToUrl util missing

I created a new application using the vue-lite net core template on 5.9.3, and the PostFileToUrl http util missing seems to be missing?

These were only added to the .NET v4.5 build prior to .NET Standard adding support for HttpWebRequest. I’ve moved them to all builds + added async overloads which are now available from the latest v5.9.3+ now available on MyGet.

If you clear your NuGet packages and restore you should download the latest version, e.g:

$ nuget locals all -clear
1 Like

Thanks! This maybe beyond the scope of your help but is there an easy way to do this multi-form post equivalent with the http utils?

const FormData = require('form-data');
const axios = require('axios');
const fs = require('fs');

const form = new FormData();

form.append('filename', '')
form.append('attachment', fs.createReadStream('./img.png'));

axios({
  method: 'post',
  url: 'https://api.clickup.com/api/v2/task/123/attachment',
  data: form,
  headers,
})
  .then(() => console.log('success'))
  .catch(() => console.log('fail'));

Note - Make sure that your file is named attachment otherwise the API will not recognize the file.

You’d need to do a multiple HTTP file upload, here’s the 2nd google result I found that uses FormData:

Here’s MDN docs for using FormData:

I didn’t communicate my question clearly. I’m asking if there is an easy way using the Service Stack http utils (c#) to post ONE file and set the form data with those two fields only. It is for posting ONE file to a task in clickup from the server.

This is the Restsharp equivalent:

var client = new RestClient(“https://api.clickup.com/api/v2/task/c4fbz1/attachment”);

var request = new RestRequest(Method.POST);

request.AddParameter(“filename”, “test.csv”);
request.AddFile(“attachment”, “/C:/Users/sbose/Downloads/original_email_JQ4pJ.html”);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Have a look at the PostFile* API examples in FileUploadTests.cs. The *WithRequest lets you send additional params via the typed Request DTO.

1 Like

Perfect, thank you a million, I didn’t want to add another dependency, code was super simple:

var cl = new JsonServiceClient("https://api.clickup.com/api/v2/task/123/");
using var ms = new MemoryStream(Encoding.UTF8.GetBytes(fileContents));
cl.PostFileWithRequest<object>(relativeOrAbsoluteUrl:"attachment", ms, 
    request: new {}, fileName: "test2.csv", fieldName: "attachment");
1 Like