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:
- //following block pulls required user values out of ticket fields
- var first=$CS.getValue("ServiceReq_User_UDF_CHAR11");
- var initial=$CS.getValue("ServiceReq_User_UDF_CHAR10");
- var last=$CS.getValue("ServiceReq_User_UDF_CHAR3");
- var clock=$CS.getValue("ServiceReq_User_UDF_CHAR5");
- var paycom=$CS.getValue("ServiceReq_User_UDF_CHAR6");
- var program=$CS.getValue("ServiceReq_User_UDF_CHAR7");
- var template=$CS.getValue("ServiceReq_User_UDF_CHAR12");
- //following block builds the URL that gets sent to the ADManagerPlus API
- //constant for ADManagerPlus URL/domain/APIkey
- var admp="http://admanager:8080/RestAPI/CreateUser?AuthToken=9c935bce-945f-4e84-82f2-18296539f457&domainName=domain.com&inputFormat=[{"
- //concatenate variables onto URL
- var admpURL= admp + '"givenName":"' +first+ '","initials":"' +initial+ '","sn":"' +last+ '","templateName":"' +template+ '","EmployeeType":"' +paycom+ '","EmployeeNumber":"' +paycom+ '","EmployeeID":"' +clock+ '"}]'
- //url encode it
- var encodedURL=encodeURI(admpURL)
- //following block sends a JSONP request to the API to create the account
- jQuery.ajax({
- url: encodedURL,
- type: 'GET',
- dataType: 'jsonp',
- jsonpCallback: 'SCPRESPONSE',
- success: function(data){
- //Do stuff
- },
- error: function(data){
- //Do stuff
- }
- });
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?