Legacy Dev Forum Posts

 View Only

Sign Up

translationMap for Custom Action is not working

  • 1.  translationMap for Custom Action is not working

    Posted 06-05-2025 18:40

    husseinco | 2018-06-02 22:48:00 UTC | #1

    Hi All,

    I have the following JSON response from Postman

    { "result": { "UserID": "112233@test.com", "Name": "Test User", "Email": "test@test.com" } }

    so I configured my response config like this:

    { "translationMap": { "UserID": "$.UserID", "Name": "$.Name", "Email": "$.Email" }, "successTemplate": "{\r\n \t\"UserID\": ${UserID},\r\n \t\"Name\": ${Name},\r\n\"Email\": ${Email}\r\n }" }

    But I keep getting an error indicating that "There was an error updating -The name of my action-" when I try to Run Action, So is this is the proper way to do the TranslationMap for the above JSON format ?

    Any assistance would be appreciated.


    Jason_Mathison | 2018-06-04 13:37:56 UTC | #2

    It looks like you need to have your translation map dig into the "result" object, so something like:

    $.result.UserID for the user id.

    By the way, I typically use http://jsonpath.com to work my way through the JSON Path translation maps.


    husseinco | 2018-06-04 15:27:34 UTC | #3

    @Jason_Mathison

    Hi Jason,

    I already tried to add the $.result.UserID into my translationMap but still same error appears here is my entire configuration

    https://community.genesys.com/communities/community-home/digestviewer/viewthread?MessageKey=86d04c9b-c02e-408f-89e5-83ec97086000&CommunityKey=bab95e9c-6bbe-4a13-8ade-8ec0faf733d4&tab=digestviewer#bm86d04c9b-c02e-408f-89e5-83ec97086000

    here is the error message I'm getting when try to Run the Action button to test


    Jason_Mathison | 2018-06-04 15:36:30 UTC | #4

    Take a look at your configuration -> request configuration in the UI. It should make it clear what the issue is.


    husseinco | 2018-06-04 16:15:48 UTC | #5

    This is my request config

    { "requestUrlTemplate": "https://instance.service-now.com/api/Example/getemplyee?employeenumber=${input.employeenumber}", "requestType": "GET", "headers": { "Authorization": "Basic 0000000000000", "Cache-Control": "no-cache", "Content-Type": "application/json", "Accept": "application/json", }, "requestTemplate": "${input.rawRequest}" }

    I tested same headers on Postman & Fiddler and both are working fine and I don't know if I miss something !?


    Jason_Mathison | 2018-06-04 17:16:04 UTC | #6

    Your request config is not valid JSON. The UI should have a red box with an X in it showing you where the JSON is invalid.


    husseinco | 2018-06-04 17:48:09 UTC | #7

    Here is screenshot of my request config

    ** I have used the same configuration on different APIs and it's working fine but for this customer it keep throwing this weird error.


    Jason_Mathison | 2018-06-04 18:03:57 UTC | #8

    The screenshot is different then the text that you pasted into this thread. In the text version you had a comma at the end of the accept header line without another header after that, which is not valid JSON. In your screen shot that comma is gone.

    Could you use the "export" button to dump your configuration? It will dump out your configuration into a text file. Feel free to replace anything you need to block out with xxxx or whatever.

    If you are not comfortable with that recopy each of the 4 parts of your configuration again to this thread (after redacting as needed).


    husseinco | 2018-06-04 18:33:35 UTC | #9

    I had to get rid of the Host name and mistakenly forgot to remove the comma while posting the the comment

    here is the exported configuration

    <a class="attachment" href="/forum/uploads/db6296/original/1X/161ae18b08551e53aec9a509176fb523a7caaeff.json">ReteriveEmployeeCategory-20180604213114.custom.json</a> (1.8 KB)


    Jason_Mathison | 2018-06-04 20:06:03 UTC | #10

    After I imported your action, test mode seems to work as expected (it fails on the non-existent host in requestUrlTemplate, however that is after the action has been updated).

    About the only troubleshooting step I have left is to either refresh or close/open your web browser that you are administering this action to make sure that the action hasn't been corrupted in memory.

    Assuming that doesn't work, please open up a support case so we can formally dig into this issue.


    husseinco | 2018-06-04 20:30:15 UTC | #11

    Thank you @Jason_Mathison, In fact I have already opened a ticket 4 days ago and uploaded the log as required but still no reply so far ! I also tried it on different PCs & browsers but no luck, and by the way I just noticed something when I change the "Accept" header to "text/json" it throws this error

    but the allowed Accept headers for this API as Postman response is


    Jason_Mathison | 2018-06-05 12:56:49 UTC | #12

    "text/json" is not in the list of content types that the web service indicates that it can handle. What behavior were you expecting?


    husseinco | 2018-06-05 13:09:47 UTC | #13

    Hi Jason, I modified the request config to

    { "requestUrlTemplate": "/api/EXAMPLE/getemplyee?employeenumber=${input.employeenumber}", "requestType": "GET", "headers": { "Content-Type": "application/json", "Accept": "application/json", "Cache-Control": "no-cache", "Host": "instance.service-now.com", "Authorization": "Basic cHVyZS5jbG91ZDpQdXIkQz00000" }, "requestTemplate": "${input.rawRequest}" }

    and new error appears 400 bad request

    any thoughts on what might be the case !


    tim.smith | 2018-06-05 13:11:53 UTC | #14

    husseinco, post:13, topic:2941
    "requestUrlTemplate": "/api/EXAMPLE/getemplyee?employeenumber=${input.employeenumber}",

    Is that really the URL? EXAMPLE doesn't seem right and employee is misspelled.


    husseinco | 2018-06-05 14:35:06 UTC | #15

    Hi tim, no it's not I just removed the actual URL for confidentiality sake.


    Jason_Mathison | 2018-06-05 13:30:53 UTC | #16

    The latest error is because your requestUrlTemplate is incorrect. That value should have the entire path to the resource, so https://foo.servicenow.com/api/EXAMPLE/foo?bar=foobar

    "Host" is not a configuration attribute that we support. Did you see that in an example somewhere?

    I added BPIVR-1573 to our internal issue tracking system to give a better error message in the future.


    husseinco | 2018-06-05 13:32:40 UTC | #17

    I saw it in the generated snippet of Postman and thought this might solve my issue as I'm struggling to get it work


    husseinco | 2018-06-05 14:36:16 UTC | #18

    @Jason_Mathison & @tim.smith, I just ran the API on FireFox and checked the response I'm getting and noticed that the response coming back from Service-now is not like the other APIs I tested successfully, please have a look on the below screenshots for more understanding

    the response for the Non-working one

    the working ones

    Second screenshot

    Third screenshot

    so does this response has something to do with the error I'm getting ! if yes how could I fix it please ?


    Jason_Mathison | 2018-06-05 14:27:35 UTC | #19

    The non-working response appears to be in XML. Neither Data Actions nor the bridge web service connector can process XML responses. You would need to see if ServiceNow has a different API that returns the data you need as JSON or create an intermediary service to translate between XML and JSON.

    From what I have seen ServiceNow has pretty solid JSON/REST support. Maybe try this API: https://developer.servicenow.com/app.do#!/restapidoc?v=jakarta&id=c_TableAPI


    husseinco | 2018-06-05 14:42:17 UTC | #20

    Thank you @Jason_Mathison, but I'm a bit confuse now because when I run the API on Postman and Fiddler the response is in JSON format !


    Jason_Mathison | 2018-06-05 15:02:03 UTC | #21

    Please escalate your support ticket for this issue. It seems like this issue needs to be completely reproduced to understand what is going wrong for you.


    husseinco | 2018-06-06 22:10:35 UTC | #22

    @Jason_Mathison Problem solved as it turned out the returning response is XML so I had to contact the team who developed it to change it to JSON and now it's working fine.

    Thank you for your kind assistance.


    Jason_Mathison | 2018-06-07 12:59:12 UTC | #23

    I'm glad you could get this resolved!


    system | 2018-07-08 12:59:15 UTC | #24

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 2941