panoramicdata / ServiceNow.Api

ServiceNow REST API nuget package
MIT License
21 stars 18 forks source link

Endpoint for Upload attachments #21

Open prajon84 opened 1 year ago

prajon84 commented 1 year ago

👋

I am looking for endpoint to "upload attachments". I find "download attachments" endpoint but nothing for upload.

https://github.com/panoramicdata/ServiceNow.Api/blob/main/ServiceNow.Api/ServiceNowClient.cs

Please guide 🙏

prajon84 commented 1 year ago

@davidnmbond

KKSatish commented 1 month ago

upload attachment functionality is not yet supported. you need to fork repo and add your custom component to add attachment.

////sample code.. var options = new RestClientOptions("") { MaxTimeout = -1, }; var client = new RestClient(options); var request = new RestRequest("https://{your_instance}.service-now.com/api/now/attachment/upload", Method.Post); request.AddHeader("Accept", "application/json"); request.AddHeader("Authorization", "Bearer {your bearer token}"); request.AlwaysMultipartFormData = true; request.AddParameter("table_name", "{table name}"); request.AddParameter("table_sys_id", "{table sys Id}"); request.AddFile("uploadFile", "/path/to/file"); RestResponse response = await client.ExecuteAsync(request); Console.WriteLine(response.Content);

prajon84 commented 4 weeks ago

Thanks @KKSatish and no worries. I deviated away from this path long back.