attachment issue

Kishor Mudhili
Giga Guru

guys,

 

I have a query, I’m working on integration. 3ed party  system creating the request from their end updated the attachment , but in ServiceNow we are unable to create the attachment to the reference ticket (everything is working without attachment part).

In the payload they are not providing any Content type, they confirmed they didn’t provide any content type for any integration  My query is: can we create attachment in ServiceNow without providing “Content type”?

 

Can you please let me know. how can it’s possible create attachment in ServiceNow without providing “Content type »

 

 

It’s really helping to me your updates 😊 😊 😊

2 REPLIES 2

johnfeist
Mega Sage
Mega Sage

Hi Kishor,

 

Content type is not a mandatory field.  However, since the files to be attached should have filename and extension, it is not a difficult task to determine the content type.  If you go to one of your instances that has a good number of attachments, you should be able to identify the majority of the relationships between extension and content type.  Simply grouping the contents of sys_attachment by content type will show you the ones you currently use.

 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Amit Gujarathi
Giga Sage
Giga Sage

Hi @Kishor Mudhili ,
I trust you are doing great.

Firstly, to create an attachment in ServiceNow, you need to provide the Content Type for the file being attached. The Content Type indicates the format of the file being attached, such as "application/pdf" for a PDF file or "image/png" for a PNG image.

Without providing the Content Type, ServiceNow will not be able to process the attachment correctly, and it will not be attached to the reference ticket.

However, if the 3rd party system is not providing a Content Type, you may still be able to create the attachment in ServiceNow by guessing the Content Type based on the file extension. For example, if the attachment is a PDF file, you can set the Content Type to "application/pdf".

Here is an example of how you can create an attachment in ServiceNow using GlideSysAttachment API and guessing the Content Type based on the file extension:

var attachment = new GlideSysAttachment();
attachment.write(recordSysId, fileName, contentType, data);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi