ADManager Plus API JSONP Result

ADManager Plus API JSONP Result

I'm automatically creating user accounts from ServiceDesk Plus by running a script when the ticket is submitted that calls the ADManagerPlus API to create the account. That works.

If I'm manually loading the same URL in the browser, I get a response back with a success and it provides the random password automatically created by the ADManagerPlus template.

However when this same URL is passed from the script the account still gets created, but I don't get a response providing what password was set - I need to get that response so I can put the random password in the ticket for the requester. How do I get the result through JSONP?

Below is the javascript code being triggered from "fields and form rules" in SDP upon ticket creation. Note that this works - I can check AD and the account exists. I just need to add something to this code to find out the initial password:

  1. //following block pulls required user values out of ticket fields 
  2. var first=$CS.getValue("ServiceReq_User_UDF_CHAR11"); 
  3. var initial=$CS.getValue("ServiceReq_User_UDF_CHAR10");
  4. var last=$CS.getValue("ServiceReq_User_UDF_CHAR3"); 
  5. var clock=$CS.getValue("ServiceReq_User_UDF_CHAR5"); 
  6. var paycom=$CS.getValue("ServiceReq_User_UDF_CHAR6");
  7. var program=$CS.getValue("ServiceReq_User_UDF_CHAR7");
  8. var template=$CS.getValue("ServiceReq_User_UDF_CHAR12");

  9. //following block builds the URL that gets sent to the ADManagerPlus API
  10. //constant for ADManagerPlus URL/domain/APIkey
  11. var admp="http://admanager:8080/RestAPI/CreateUser?AuthToken=9c935bce-945f-4e84-82f2-18296539f457&domainName=domain.com&inputFormat=[{"
  12. //concatenate variables onto URL
  13. var admpURL= admp + '"givenName":"' +first+ '","initials":"' +initial+ '","sn":"' +last+ '","templateName":"' +template+ '","EmployeeType":"' +paycom+ '","EmployeeNumber":"' +paycom+ '","EmployeeID":"' +clock+ '"}]'
  14. //url encode it
  15. var encodedURL=encodeURI(admpURL)

  16. //following block sends a JSONP request to the API to create the account
  17. jQuery.ajax({ 
  18.    url: encodedURL,
  19.    type: 'GET',
  20.    dataType: 'jsonp',
  21.    jsonpCallback: 'SCPRESPONSE', 
  22.    success: function(data){ 
  23. //Do stuff
  24.    },
  25.    error: function(data){ 
  26. //Do stuff
  27.    }
  28.  }); 

This URL shows a normal API success response that lists the user password, which is the same as what I get if manually calling the API from my browser, but I'm getting nothing back calling the API from the script:

                New to ADSelfService Plus?