saveResponseBodyAsAttachment is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 10:34 AM
I am using below code to save the outbound REST (GET) calls response to save in attachment table but it's not working, the code is not getting executed even if I comment out highlighted line of code. this returns response when we do not try to save the response, what am I missing? I followed - link
Note: Unable to use background script because it needs O-auth, non O- Auth link works in background script - Link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 11:00 AM
Hi
please do not call response.getBody() after execution of REST message. You can load the response as an attachment or fetch the response body as text, but not both!
For a working example please see https://developer.servicenow.com/blog.do?p=/post/saving-restmessagev2-responses-as-attachments/
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 01:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 07:48 PM
Hi
there are tons of reason why it doesn't work for you and I really miss some debugging approaches from you. Neither I can read your thoughts nor I have access to your instance. Therefore, it is on you to provide ALL required information to help us understand your issue better,
For example:
- In your REST Message object "RightAnswers article import" what happens if you open the URL configured at REST method "GET images". Can you see the image in your browser?
- If yes: Did you increase the logging level for the REST message method "GET images" and did you check the respective records at table sys_outbound_http_log? Which status code is returned? Are there any meaningful log errors?
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 06:49 AM
2. I checked the HTTP outbound log table and I see that I am getting error that '[ERROR Code :200 ] unable to save response body as attachment: user not authorized' though I have provided admin and knowledge admin role to the MID server user as we are trying to connect through MID server.
Thanks,
Govind