Adding an attachment to incident REST API

diomedesdomingu
Giga Contributor

Hi, I developed an application in ASP.NET Web API that allows me to upload attachment to an incident when this is created, all this using Service-Now REST API and Table API. I works perfect in the development environment (locally) but when I deploy it to production (MS Azure) I'm getting an odd issue: the file is uploaded but when I try to check directly in Service-Now, its opens/download as a corrupt file. I tried with different kinds of files (PNG, BMP, PDF,...) but I'm getting the same issue. Also, I double checked the Content-Type header and is correct in every case.

BTW.: We have the latest upgrades of May 2016

1 ACCEPTED SOLUTION

diomedesdomingu
Giga Contributor

To resolve this, using RestSharp, I'm using the Stream of the file instead of saving the file in the website and later uploading to ServiceNow.


View solution in original post

4 REPLIES 4

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Diomedes,



Are you using the REST attachment api?


This could be the best approach.


Attachment API


If so you should be aware that a couple of the curl code snippets, displayed by the API Explorer, for uploading attachments are incorrect.


ServiceNow KB: PRB646918: REST API Explorer Attachment API curl snippet problems (KB0551442)  



If the above is not relevant, could you supply more details on how you are carrying out the upload?



Best Regards



Tony


Hi Tony, I think that you misunderstood my problem: I don't have any issue to create an attachment to an incident, the problem is when I use the same process in Microsoft Azure Websites.


diomedesdomingu
Giga Contributor

To resolve this, using RestSharp, I'm using the Stream of the file instead of saving the file in the website and later uploading to ServiceNow.


Hi,



I'm struggling to get attachments to upload (using HttpClient in C#), are you able to share your code?



Currently receiving an error "Requested URI does not represent any resource"



Thanks,



Tim.