Overview
Excerpt |
---|
|
Test cXML Punchout using the Postman for Chrome toolUser Creation API to allow a user to be created from the Salesforce contact screen. |
This guide covers the process for testing cXML Punchout using for User Creation using the Postman for Chrome tool. There are add-ons available for other browsers, but this guide will show examples using Postman.
Use this guide to troubleshoot network connectivity and password / credential issues.
Prerequisites
- Punchout URL (i.e. https://yoursite.com.au/punchout.aspxURL (will be provided to you)
- Username
- Password
- Sample Punchout Setup Request file (see sample at the end of this article)
- API testing app / browser add-on:
...
- Open Postman.
- Enter the URL in the URL request box.
- Set the request type to 'POST'.
- Paste the sample Punchout Setup Request XML into the 'Body' dialogue box as raw data. You can find the code at the end of this article.
- Replace the #USERNAME# with your username.
- Replace the #PASSWORD# with your password.
- Click 'Send' (top right of browser window).
- If the request is successful, you will get a '200 OK' response code in the response dialogue box.
- If this is the case, you can continue on testing within your ERP system.
- If you get a blank response dialogue box (even if the status returns '200 OK'), check that the URL, your username, and password are all correct.
- If you still get a blank response, contact your supplier for further assistance.
Sample
...
Warning |
---|
You need to replace the clientId and clientSecret values below in the getToken() function with the values provided by Professional Services. |
Warning |
---|
This is not meant to be used as is, but is just an example including how you might cache the token and retry on token expiry etc. |
Code Block |
---|
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.021/cXML.dtd">
<cXML payloadID="1233444-200@ariba.acme.com"
xml:lang="en-US" timestamp="1999-03-12T18:39:09-08:00">
<Header> |
function clearToken() {
sessionStorage.removeItem('api_type_ebf530f9-083c-43a1-bf93-cd47a853495b');
sessionStorage.removeItem('api_token_ebf530f9-083c-43a1-bf93-cd47a853495b');
}
function getToken() {
// Use Cached authorization token information if available
//
var type = sessionStorage.getItem('api_type_ebf530f9-083c-43a1-bf93-cd47a853495b');
var token = sessionStorage.getItem('api_token_ebf530f9-083c-43a1-bf93-cd47a853495b');
var result = $.Deferred();
if (type != null && token != null) {
result.resolve({
type: type,
token: token
});
return result.promise();
}
// TODO replace these values with your clientId and client secret values
var clientId = '<replace>';
var clientSecret = '<replace>';
var auth = btoa(clientId + ":" + clientSecret);
// Get and Cache new authorization token.
//
$.ajax({
url: 'https://justinw-office.commercevision.com.au/api/token',
method: 'post',
headers: {'Authorization': 'Basic ' + auth},
data: { 'grant_type': 'client_credentials' }
}).then(function(response) {
type = response.token_type;
token = response.access_token;
sessionStorage.setItem('api_type_ebf530f9-083c-43a1-bf93-cd47a853495b', type);
sessionStorage.setItem('api_token_ebf530f9-083c-43a1-bf93-cd47a853495b', token);
result.resolve({
type: type,
token: token
<From>});
});
return result.promise();
}
function createUser(user) {
function <Credential domain="AribaNetworkUserId">
createOptions(tokenInfo) {
return {
<Identity>admin@acme.com</Identity> url: 'https://justinw-office.commercevision.com.au/api/User',
method: 'post',
</Credential>
headers: { 'Authorization': tokenInfo.type + ' ' + tokenInfo.token },
contentType: </From>'application/json',
<To> data: JSON.stringify(user)
};
}
var <Credentialprom domain="ABN">
<Identity>112233344</Identity>= $.Deferred();
// Get token (cached or retrieve) and make call. On failure due to token having expired, retrieve
// a new token and retry.
</Credential>//
getToken().then(function(token) {
</To>$.ajax(createOptions(token))
<Sender>
.done(function(response) {
<Credential domain="AribaNetworkUserId">
prom.resolve(response);
})
<Identity>#USERNAME#</Identity>
.fail(function(response) {
if (response.status == 401) <SharedSecret>#PASSWORD#</SharedSecret>
{
</Credential>clearToken();
<UserAgent>Ariba ORMS 5.1P4 </UserAgent>
getToken().then(function(token) {
</Sender> $.ajax(createOptions(token))
</Header>
<Request>
.done(function(response) {
prom.resolve(response);
<PunchOutSetupRequest operation="create">
<BuyerCookie>34234234ADFSDF234234</BuyerCookie>
})});
<Extrinsic name="randomKey">department code</Extrinsic>
return;
<BrowserFormPost>}
<URL>http://www.hashemian.com/tools/form-post-tester.php/cxmlTest</URL>console.error(response);
</BrowserFormPost>});
});
return prom.promise();
}
createUser({
"EmailAddress" : "user-does-not-exist",
"FirstName" <SupplierSetup>: "user-name",
"Surname" : "user-surname",
"PhoneNumber" : "0419 000 000",
"NotifyEmailAddress" <URL>http://workchairs.com/cxml</URL>: "someone@somedomain.com",
"CustomerCodes" : [
</SupplierSetup>"046008",
"046018"
],
</PunchOutSetupRequest>
</Request>
</cXML>"SendWelcomeEmail": false
}).done(function(response) {
// TODO do something with the response here
console.log(response);
}); |
Related help
Content by Label |
---|
showLabels | false |
---|
max | 10 |
---|
showSpace | false |
---|
excludeCurrent | true |
---|
cql | label in ("punchout","testing") |
---|
|
...