Outbound attachment using REST API POST method from Servicenow to Opesource third Party tools(Redmine): {"status":"404","error":"Not Found"}

imed1
Tera Contributor

Hello,

I have an issue when i want to send attachment to a third party tools (Redmine).

The third party need in the header the 

Content-Type: application/octet-stream

I build my json as excpect but i my request body i have this error:

**Payload logging not supported for content-type: 'application/octet-stream'**

And i my request header i have a good json:

{Content-Length=155, Accept=application/json, Content-Type=application/octet-stream, X-SNC-INTEGRATION-SOURCE=4900085cffa314849376762fa87efe62, Authorization=Basic SU5URVJGQUNFX1NFUlZJQ0VOT1c6RjlSTzdFbVk3Ymo5bWtVTDl2cjk=, User-Agent=Jakarta Commons-HttpClient/3.1, Host=xxxxx}

In the response header i have:

Date=Tue, 25 Aug 2020 22:22:03 GMT, Server=Apache, Status=404 Not Found, X-Request-Id=1faef526-957d-4ea1-954f-0addaaaf5007, Vary=Accept-Encoding, X-Runtime=0.003372, Content-Type=application/json;charset=utf-8, Correlation-ID=, Transfer-Encoding=chunked}

Response body:

{"status":"404","error":"Not Found"}

 

Thanks in advance

1 ACCEPTED SOLUTION

imed1
Tera Contributor

The issue of 404 is fixed because the post methode not deined in the target webservice.

Best regards

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is 3rd party expecting the application/type as "octet stream"

Do you have sample request and response shared by them for better understanding on how the json should look like

Usually sending attachments to 3rd party team we usually get the base64encoded data of that attachment and then send it across.

https://community.servicenow.com/community?id=community_question&sys_id=bf8cbf1adb7157004fc2f4621f96...

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello,

 

Thanks for your reply.

If i understand your idea is to encoded the attachmentand set is to the payload paremeter but also the same error:

/***

var grSysAtt = new GlideRecord('sys_attachment');
var sa = GlideSysAttachment();
var binData = sa.getBytes(current);
var encData = GlideStringUtil.base64Encode(binData);
gs.log("Encoded data:" + encData);
sm.setStringParameter('payload', encData);

**/

The client :https://www.redmine.org/projects/redmine/wiki/Rest_api#Attaching-files

after get a token I build my upload array as excpect like this:

{
  "issue": {
    "
    "uploads": [
      {"token": "7167.ed1ccdb093229ca1bd0b043618d88743", "filename": "image.png", "content_type": "image/png"}
    ]
  }
}


find_real_file.png

Thanks for your help

@imed 

In that case you need to check whether application-type as octet-stream is supported in Outbound REST Message or not from ServiceNow.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@imed 

Is there any update on this? Is this question resolved or you need some more assistance.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader