Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

RESTMessageV2 - setQueryParameter, size limit

PhoenixMing0912
Giga Expert

Hi experts,

I have coded a very simple RESTful post and run it in Scripts-Background.

var request = new sn_ws.RESTMessageV2('RemoteServer','Post');

request.setQueryParameter("strBase64", strBase64);

I am trying to send String "strBase64" which is Base64 encoding of an attachment.

However, looks like it has a size limitation, only a couple of KB is allowed to send.

I am quite sure that it is a service now side problem because I have also tried a Java client call and it worked.

Can anyone help?

 

1 ACCEPTED SOLUTION

PhoenixMing0912
Giga Expert

This issue has been solved.

Looks like Service Now has a length limitation setting on "request.setQueryParameter()", while Java doesn't.

I used setRequestBody and large content can be sent out.

View solution in original post

8 REPLIES 8

siva_
Giga Guru

If possible can you please post the total script here

Thanks,

Siva.

First, I would get the attachment content from sys id.

var gr = new GlideRecord("sys_attachment");
gr.addQuery("sys_id", '85b034c1dbe6e3403aff6a494896199b');
gr.query();
if (gr.next()){
var gsa = new GlideSysAttachment();
var binData = gsa.getBytes(gr);
var strBase64 = GlideStringUtil.base64Encode(binData);
}

I tried to send "strBase64" as request query parameter but if it was big(e.g., 200KB+), I would got an error and return http status with 400.

hvrdhn88
Giga Patron

if i am not wrong you want to send the attachment to other tool .

if yes have you tried to use "setRequestBodyFromAttachment()" .

 

Doc Link below

 

setRequestBodyFromAttachment()

 

Example:

 

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

 

Regarding the size of the request .

 

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/custom_web_services/ref...

 

Hope it will help you.

hvrdhn88
Giga Patron

any updated on this thread?

if my response helped you then kindly mark the answer correct and close this thread.