I'm trying to generate/request a token for Postman, and it seems like I've set things up correctly (no more error messages), but I don't see the token anywhere. I'm fairly certain that it's simply due to my complete lack of experience in setting these up. So ..
In PureCloud, I set up a client with
In Postman/Get New Access Token
- Auth URL: https://login.{{environment}}/oauth/authorize
- Access Token URL: https://login.{{environment}}/oauth/token
- Client ID from PureCloud
- Client Secret from PureCloud
- Scope (blank)
- Grant Type: Authorization Code
- Request access token locally - checked
Hitting [Request Token] brings up the result window briefly, but I don't see any new tokens appearing in list of existing tokens, and sending my request continues to result in 'Please authenticate'.
What steps am I missing/have I mishandled, please?
Thanks!
Duncan
Request access token locally - checked
Uncheck that and give it a try.
Progress! Tokens are now showing up in the list. I cleared the list (compulsive clicking), requested a new token and selected it. I now have the option of adding it to either the header or the URL; both appear to have the same response when I click [Send], returning 'Please authenticate'.
Make sure the authorization header is set on the request. It should look like this if you clicked the "Use Token" button on the Authorization tab:

If the value for the authorization header is bearer {{token}}
, be sure that you have the correct postman environment selected, that you have a variable named token
(or whatever yours says), and that you have copied the auth token into that variable.
There's a link under the Save button that says Code. If you click that, you'll see the exact HTTP request that will be sent. Be sure that your token is being displayed correctly there. If it's not, your configuration isn't correct. It should look like this:

After watching the video again(Making API calls to PureCloud with Postman), I used Import from link to pull in the User API and that seems to be fine, i.e. 'Get current user details' and 'Get the list of available users' work fine, so the issue doesn't appear to be OAuth per se.
Using the same token in a call to validate my webservice.datadip action method continues to result in a 'Please authenticate' message.
https://apps.{{environment}}/bridge/api/v1/actionCall/getInventoryDetails?contactId=0034000000hCiop
I'm not sure what the parameter(s) for the built-in/Salesforce datadip actions are, or how to reference them. I know one uses the Call/Task.ANI to search within Salesforce, but I don't know how to reference that in the URL ^. It would help to be able to tell whether the issue lies in the token being incorrect for use with Actions, or whether Actions need to be tested some other way.
I've built out a partial IVR using a combination of the Salesforce datadip action, retrieving the Contact details from Salesforce, and then use the Contact.Id to call my own action. The IVR is pulling the Contact information correctly, but the next step is where it's failing, hence the Postman wrangling.
Thanks for any help that you can provide.
Sorry, I didn't understand the context of your post. OAuth logins are for the PureCloud Platform API. It appears you're doing something else. What are you trying to accomplish?
We have two connectors in place to our Salesforce instance: the Salesforce datadip connector and the Webservices datadip. I'm in the process of building out an IVR that uses actions from both, but the webservices action is failing, and I'm trying to figure out why.
I'm trying to use Postman to figure out what the issue might be, and I was hoping I could get to these Actions through the PureCloud Platform API connection, but I only see the pre-built services, i.e. PureCloud API v2 - Users, or the native Postman ones such as Postman Echo; I can't seem to access the connector Actions.
Plus, if I could access them both (Salesforce connector actions, & webservices connector actions), I'm not sure what the parameters are or their format for the Salesforce datadip connector to test it through Postman. I assume it's the Call.ANI, but I don't know how to format that.
Make sure that the value of your authorization header has bearer
in all lower case. It won't work if it's sent as Bearer
, which is what postman defaults to.
Thanks, Tim -- mischief managed! (I don't suppose there's a way to automatically default Postman, but manually updating the header in the short term is fine.)
On to the next issue, I'm now seeing the following error in Postman, that appears to indicate that the response payload isn't matching the schema that I set up..?
{
"ok": false,
"received": 1493665281584,
"ms": 396,
"correlationId": "ae764674-2479-49d0-b5b6-10bd64de8f97",
"result": {
"message": "Could not expand request payload",
"name": "BadRequestError",
"statusCode": 400,
"data": {}
}
}
I have 'flatten metadata' checked on the Action; does this indicate that my Response Schema is incorrect?
The request hasn't been sent to your connector at that point. The error indicates that there was an error flattening the input data into the input request schema. Are you using periods or other non-alphanumeric characters in your request schema?
Not that I'm aware of. This is the schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Patient Inventory request",
"description": "Schema to retrieve Delivery Schedule details via Contact Id",
"type": "object",
"properties": {
"ContactId": {
"type": "string",
"description": "Salesforce Contact Id"
}
},
"additionalProperties": true
}
and this is what the Post URL looks like:
https://apps.{{environment}}/bridge/api/v1/actionCall/getPatientInventoryDetails?ContactId=0034000000hCiop
Hey Duncan,
After some testing locally we were able to reproduced your error exactly when not sending a JSON body to the action call invocation. All actions require a JSON body, even if it is just an empty object (e.g. {}
). Additionally Bridge does not forward URL parameters for security reasons, so any parameters must be encoded in the body. In this case I think what you want is: {"ContactId": "0034000000hCiop"}
. You can enter that in POSTMAN as Body->Raw->JSON.
I'll create a ticket to add more helpful error data in this condition in the future.
Cheers!
Eric
1 Like
Thanks, Eric --
In that case, I leave the Action name as is in the Post
https://apps.{{environment}}/bridge/api/v1/actionCall/getPatientInventoryDetails
and put {"ContactId": "0034000000hCiop"}
in the Body.
It does change the error message, which is progress, to this:
{
"ErrorCode": "ServerError",
"Message": "Error during Action execution."
}
Which looks like I've reached the end of Postman's usefulness for the moment; something about how I've defined the Action is apparently at issue.
What do you get if you post that body directly to your service (the endpoint configured on the action) without going through the bridge server?
I'm not sure yet; I haven't the slightest idea how to connect Postman directly to Salesforce (there are tutorials, but it's a bit late in the day to try one out at the moment), but my coworker uses Soap.UI (he was out last week) so we can maybe try that in the morning.
(some time later ...)
Connecting to my (now) REST service directly using workbench, I can do the following:
Post to: /services/apexrest/inventory_schema_retrieval/getInventorySchema
passing:
{ "contactId" : "0034000000hCiop" }
returning
{
"shipDate" : "2017-05-05",
"patientID" : "11802.0",
"isPureflowwWarmer" : true,
"isPureflow" : true,
"hasWastelines" : false,
"deliveryDate" : "2017-05-15"
}
So now I/we need to figure out how to pack that request in Postman so that I can leverage the response from the Salesforce DataDip that retrieves that contactId value in the first place.
You'll need to look in the bridge connector logs to see what's going on with the request. You should be able to get more information about why it's failing in the logs than you're getting from the response in postman. Information about the logs can be found in the Troubleshoot the web services data dip connector resource center article.
To answer your question about authentication you posted in another topic, you need to handle authentication on your own in your service. If you're trying to hook up the bridge action directly to salesforce, it probably won't work because salesforce is going to want authentication that the bridge server isn't going to provide. You'll need a middleware web service to sit between the bridge server and salesforce so it can format the request/response correctly for both sides and handle authentication with salesforce.