Attachement API File Post - Reading file from system into request body?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 10:33 AM
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('post');
request.setEndpoint('https://dev261030.service-now.com/api/now/attachment/file?table_name=ZZ_YYsc_cat_item&table_sys_id=7...');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('Content-Type', 'image/png');
request.setBasicAuth('#######','#########');
//How do I read the system file 'C:/Users/rwebb1/OneDrive - Klein ISD/Desktop/picture.png' into the request body?
//request.setRequestBody('data-binary', '@C:/Users/rwebb1/OneDrive - Klein ISD/Desktop/picture.png');
var response = request.execute();
gs.info("http response status_code: " + response.getStatusCode());
gs.info("http response boddy: " + response.getBody());
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 05:55 PM
That API only works from whatever can emulate a browser.
In fact if you look at code samples for this API in the REST API Explorer - as apposed to other APIs, only contains a cURL example, which is basically a browser.
If servers had the capability to arbitrarily read out local files from users' computers, that would be hackers', even wannabe hackers' paradise.