Bigcommerce Process Payment with api 401 error with code 10001 - javascript

i just started working with bigcommrce payment API and unable to solve the error 401 unauthorized.
here is the sample data i have tried
{
"payment": {
"instrument": {},
"payment_method_id": "cod",
"amount": 81,
"currency_code": "PKR"
}
}
and
{
"payment": {
"instrument": {
"type": "card",
"number": "4111111111111111",
"cardholder_name": "BP",
"expiry_month": 12,
"expiry_year": 2020,
"verification_value": "411"
},
"payment_method_id": "authorizenet.card",
"save_instrument": true
}
}
but still getting the response of 401
I have set the authorization token (Payment Access Token) already with the other two headers.

One likely cause of a 401 is the formatting of the payment access token header. It needs to be:
Authorization: PAT token.goes.here, with PAT in all caps and a space between the word PAT and the token. Hope that helps!

Related

How to get JSON payload sent by the Slack action message?

I am trying to build a Slack bot with interactive buttons. I have set up a Google Apps Script to handle the action performed on the Slack message. I want the payload of the request sent by the Slack. I have tried to get the request object by doing
function doPost(e) {
return processComment(e);
}
function processComment(e) {
Logger.log(e);
}
{postData=FileUpload, queryString=method=slack, parameter={method=slack, payload={"type":"block_actions","user":{"id":"U01835Mxxxx","username":"ravsamteam","name":"ravsamteam","team_id":"T0160UQZZZZ"},"api_app_id":"A018MPZ2xxx","token":"NTNRCTPDz8mxxxzxxxxxxxxx","container":{"channel_id":"C0190D8L2AU","is_ephemeral":false,"message_ts":"1597154895.001500","type":"message"},"trigger_id":"1281039280903.1204976558018.aa1055f6900d7884d9cd4ac34ffzzzzz","team":{"id":"T0160UQGE0J","domain":"ravsamhq"},"channel":{"id":"C0190D8L2AU","name":"blogs"},"message":{"type":"message","subtype":"bot_message","text":"This content can't be displayed.","ts":"1597154895.001500","bot_id":"B019BNL08BS","blocks":[{"type":"section","block_id":"mNavk","text":{"type":"mrkdwn","text":" New comment on RavSam's blog by hello","verbatim":false}},{"type":"section","block_id":"v3Ip","text":{"type":"mrkdwn","text":"*Blog:*\nhello\n\n*Comment:*\nravgeet errorCannot read property 'payload' of undefined","verbatim":false}},{"type":"actions","block_id":"1maVO","elements":[{"type":"button","action_id":"WSo=","text":{"type":"plain_text","text":"Approve","emoji":true},"style":"primary","value":"approved"},{"type":"button","action_id":"Vek\/","text":{"type":"plain_text","text":"Deny","emoji":true},"style":"danger","value":"denied"}]}]},"response_url":"https:\/\/hooks.slack.com\/actions\/T0160Uxxxxx\/1301968xxxxxx\/Q3gZhbeUCUIxxxxxxxxxxxxx","actions":[{"action_id":"WSo=","block_id":"1maVO","text":{"type":"plain_text","text":"Approve","emoji":true},"type":"button","value":"approved","action_ts":"1597213837.152704"}]}}, contentLength=2391.0, parameters={payload=[Ljava.lang.Object;#53f2e9fa, method=[Ljava.lang.Object;#5793298b}, contextPath=}
How do I get the payload? Once I have the payload JSON, I can use the actions to determine what action was taken by the user?
Yes. The payload contains all the information you need to identify the action. And it also contains a response_url to respond back.
Slack payload should look like this.
{
"actions": [
{
"name": "channels_list",
"selected_options": [
{
"value": "C012AB3CD"
}
]
}
],
"callback_id": "select_simple_1234",
"team": {
"id": "T012AB0A1",
"domain": "pocket-calculator"
},
"channel": {
"id": "C012AB3CD",
"name": "general"
},
"user": {
"id": "U012A1BCD",
"name": "musik"
},
"action_ts": "1481579588.685999",
"message_ts": "1481579582.000003",
"attachment_id": "1",
"token": "iUeRJkkRC9RMMvSRTd8gdq2m",
"response_url": "https://hooks.slack.com/actions/T012AB0A1/123456789/JpmK0yzoZDeRiqfeduTBYXWQ",
"trigger_id": "13345224609.738474920.8088930838d88f008e0"
}
You can learn more here.

Teams botframework send proactive message REST api

I Try to create new converation and send proactive message with teams bot (botfreamwork).
I used this document to do that.
I POST to : SERVICE_URL/v3/conversations/
BODY:
{
"bot": {
"id": BOT_ID
},
"members": [
{
"id": USER_ID
}
],
"channelData": {
"tenant": {
"id": TENANT_ID
}
}
}
BOT_ID - I put the app id of the bot (with a prefix of "28:")
USERֹ_ID - I copied the USER_ID from a message I received from the user (not in a proactive message)
TENANT_ID - I took the tenant id from the link of the teams
I get this error:
{
"error": {
"code": "BadSyntax",
"message": "Invalid user identity in provided tenant"
}
}
I made several attempts to change the user ID: I changed to a user that appears in ADD, I changed with a prefix of 29: and without a prefix of 29: - nothing helped, this error continues to appear.
What am I missing?

Error: "Username value length exceeds 20 characters" when calling Sabre CarAvailability in Postman

I am trying to make a POST request to the Sabre CarAvailability API with Postman. When I make the request I get back the following error: Username value length exceeds 20 characters.
I obtained a bearer token and added it to the authorization section of my request
I added the carAvailabilityRequest object as raw data, in the body section of the request.
I tried changing the values of this object, but so far without luck. I know I am doing something wrong but I have no idea what.
Here is the carAvailabilityRequest object I passed:
{
"OTA_VehAvailRateRQ":
{
"TimeStamp": "string",
"Version": "string",
"ReturnHostCommand": true,
"VehAvailRQCore":
{
"RPH": 0,
"QueryType": "Quote",
"VehRentalCore":
{
"PickUpDateTime": "03-31T09:00",
"ReturnDateTime": "04-05T11:00",
"PickUpLocation":
{
"LocationCode": "DFW",
"CityLocation": "string"
},
"ReturnLocation":
{
"LocationCode": "DFW"
}
}
}
}
}
The request does not get through and I get the following error message:
{
"Fault": {
"faultcode": "{http://schemas.xmlsoap.org/soap/envelope/}Client.EbXmlFieldTooLong",
"faultstring": "Username value length exceeds 20 characters",
"detail": {
"StackTrace": [
"com.sabre.universalservices.base.exception.InvalidEbXMLException: errors.xml.USG_EBXML_FIELD_TOO_LONG"
]
}
},
"Links": [
{
"rel": "self",
"href": "https://api-crt.cert.havail.sabre.com/v2.4.1/shop/cars"
},
{
"rel": "linkTemplate",
"href": "https://api-crt.cert.havail.sabre.com/<version>/shop/cars"
}
]
}
Please help me solve this issue - thanks in advance.
Just from the message "Username value length exceeds 20 characters" I would expect that something is wrong with your authentification.
When following the link in your error response https://api-crt.cert.havail.sabre.com/v2.4.1/shop/cars it says again that something is wrong with your authentification/the authentification data is missing:
It seems that something is not configured correctly with your authentification/bearer token or are you maybe sending to a wrong endpoint?
Something else you could try is setting the Content-Type of your request body to application/json because the API documentation you provided seems to define it this way.
You can do this in Postman in the Headers tab of your request:
I tried it out myself with the same error message using the version v2.4.1
If you make the same request to a previous version you will get an appropiate answer.
Use v2.4.0
https://api-crt.cert.havail.sabre.com/v2.4.0/shop/cars
HTH
Pablo.

Fetch all emails across all Gmail contact groups

I am trying to fetch all the emails from the user contacts using JS library.
Setup
1.) Initialised the gapi client using
gapi.client.init({
apiKey: config['google']['apiKey'],
discoveryDocs:
["https://www.googleapis.com/discovery/v1/apis/people/v1/rest"],
clientId: config['google']['appId'],
scope: "https://www.googleapis.com/auth/contacts.readonly"
})
2.) After the user grants permission, I try to fetch the contact details
gapi.client.people.people.connections.list({
'resourceName': 'people/me',
'pageSize': 500,
'personFields': 'names,emailAddresses'
}).then((response) => {
let connections = response.result.connections;
console.warn(connections);
})
3.) From step 2, I get zero connections.
However, when I perform
gapi.client.people.contactGroups.list()
I get following response
{
"contactGroups": [
{
"resourceName": "contactGroups/all",
"groupType": "SYSTEM_CONTACT_GROUP",
"name": "all",
"formattedName": "All Contacts",
"memberCount": 13
},
...
],
"totalItems": 9,
"nextSyncToken": "EJjRiq3lnNYC"
}
From the response, I can see that in contactGroups/all group, I have 13 contacts and in my account i can see the same number of contacts.
So, what is the proper way to get all the contacts across all the contact groups using JS library?
I've tried using gapi.client.people.people.connections.list and successfully got 200 response. I also don't get equal values.
Using gapi.client.people.people.connections.list, here is the response:
....
],
"nextSyncToken": "^***",
"totalPeople": 19,
"totalItems": 19
}
While in gapi.client.people.contactGroups.list(),
{
"resourceName": "contactGroups/all",
"groupType": "SYSTEM_CONTACT_GROUP",
"name": "all",
"formattedName": "All Contacts",
"memberCount": 155
},
Be noted that people.connections.list only provides a list of the authenticated user's contacts merged with any connected profiles. While contactGroups.list lists all contact groups owned by the authenticated user. Members of the contact groups are not populated.

Google App ScriptError - 401 UNAUTHENTICATED after redeplyment

I'm getting this below exception while running the script after redeployment.Earlier it was working fine but when I added some new functions and redeployed it as API executable., started getting this error.
[17-07-08 20:48:45:404 PDT] {
"error": {
"code": 401,
"message": "ScriptError",
"status": "UNAUTHENTICATED",
"details": [
{
"#type": "type.googleapis.com/google.apps.script.v1.ExecutionError",
"errorMessage": "Authorization is required to perform that action.",
"errorType": "ScriptError"
}
]
}
}
Your OAuth scopes have probably changed. Your client needs to add these new scopes and request a new token with them.

Categories

Resources