1
0
-1

Hi - I am working with the json tool and want to make a post call. in an external tool (postman) I was able to make a successful call by setting up the following example:

Example URI


POST www,someapi.com/AjeraAPI.ashx?ew0KICAiRGF0YWJhc2VOYW1lIjogIkFqZXJhX01haW4iDQp9

and using a raw structure as the body of the call:

{
   Method: "CreateAPISession",
   Username: "janedoe",
   Password: "j@ned0e",
   APIVersion: 1,
   UseSessionCookie: false
}

so this returns the token.... my question is how do I setup the json tool in joget with the setting in body?
    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      FIXED - the issue was related to the URI ending with a "%3d". when the payload contains integers or boolean where the "" is not required the API call fails. by replacing it with the equivalent "=" sign, it works...

      Tony


        CommentAdd your comment...
      1.  
        1
        0
        -1

        Greetings - here is an update on my testing: 


        noticed that the plugin/tool has a custom json payload which is awesome! however when I entered the body below I get an X next to "method" saying "bad string". do we have some example of the format for the option?

        Headers
        Content-Type: application/json
        Accept: application/json
        Body
        {
           Method: "CreateAPISession",
           Username: "janedoe",
           Password: "j@ned0e",
           APIVersion: 1,
           UseSessionCookie: false
        }


        1. Anders

          Hi, you can try putting double quotes around the keys, for example "Method": "CreateAPISession"

        2. Anthony Sica

          Hi - I was able to successfully execute and save to form with payloads that are in " ". such as :


          {
             "Method": "ListItems",
             "SessionToken": "janedoe",
             
          "MethodArguments": { ....Filters
          } }

          However when I try to use json post payload which have a number or bolean, such 1 or false,
          it doesnt work in joget json tool. it does work in Postman and other applications fine.

          Is there a trick to passing those parameters? below is the error when trying to fetch a session key with such parameters:

          INFO 22 Mar 2020 19:28:47 org.joget.apps.app.lib.JsonTool - POST : https://ajera.com/DV00000/AjeraAPI.ashx?ew0KalsdkjgretoisddslfkhnbljkhldfhglnvmdfnmxGVEYXRhIjogZmFsc2UNCn0%3D=
          331INFO 22 Mar 2020 19:28:47 org.joget.apps.app.lib.JsonTool - Custom JSON Payload : {_ "Method": "CreateAPISession",_ "Username": "username",_ "Password": "Password",_ "APIVersion":1,_ "UseSessionCookie":false_}
          332INFO 22 Mar 2020 19:28:47 org.joget.apps.app.lib.JsonTool - Adding request header Content-Type: : application/json
          333INFO 22 Mar 2020 19:28:47 org.joget.apps.app.lib.JsonTool - Adding request header Accept: : application/json
          334INFO 22 Mar 2020 19:28:47 org.joget.apps.app.lib.JsonTool - https://ajera.com/DV007824/AjeraAPI.ashx?ew0KICAiQ2xpZW50SUQiOiA3ODI0LA0KICAiRGF0YWJhc2VJRCI6IDEzOTc2LA0KICAiSXNTYW1wbGVEYXRhIjogZmFsc2UNCn0%3D= returned with status : 200
          335INFO 22 Mar 2020 19:28:47 org.joget.apps.app.lib.JsonTool - {__ "ResponseCode": -100,__ "Message": "All requests with this API call have failed. See Errors property for details.",__ "Errors": [__ {__ "ErrorID": -150,__ "ErrorMessage": "An error has occurred.",__ "ErrorData": {},__ "ErrorObj": {}__ }__ ],__ "Content": {},__ "UsageKey": "82db2682-0f3c-4ee2-bf90-86bd3732b08b"__}


          Thanks

          Tony
        CommentAdd your comment...
      2.  
        1
        0
        -1

        I googled and found this information that might be helpful for you:

        Google Results

        1. Anthony Sica

          Hi - thank you for references. I am fairly familiar with mapping the JSON information returned with the fields in the form and manipulate them.

          my questions is regarding including the query in either the URI or as header information. the JSON tool or plugin doesnt seem to have the option for the query.... the body  above is for the call to the API get/post. 

        CommentAdd your comment...