Square-Connect 422 error when trying to add items - square-connect

I am getting a 422 error while trying to add items to my square account using the API (POST). Please let me know what is wrong.
Here is what I am sending
URL: https://connect.squareup.com/v1/me/items
Header:
Authorization: Bearer {Personal Token}
Accept: application/json
Content-Type: application/json
Body:
[{
"visibility": "PRIVATE",
"available_online": false,
"available_for_pickup": false,
"name": "New Item",
"variations": [{
"pricing_type": "FIXED_PRICING",
"name": "Regular",
"price_money": {
"currency_code": "USD",
"amount": 6000
},
"sku": "new_item"
}]
}]

The Item object being provided in the above example is inside an array, which is incorrect. If you delete the outermost square brackets from the above example, the request should succeed.

Related

How to differentiate Full Users and Team Members using REST API (MS GRAPH or WEB API)?

I need to figure out which user is "Full User" or "Team Member". Could not find any information in the documentation. Can someone help me?
Have a look at the Microsoft Graph REST API.
You could call users method to get a list of users.
Request
GET https://graph.microsoft.com/v1.0/users
Response
HTTP/1.1 200 OK
Content-type: application/json
Content-length: 608
{
"value": [
{
"businessPhones": [
"businessPhones-value"
],
"displayName": "displayName-value",
"givenName": "givenName-value",
"jobTitle": "jobTitle-value",
"mail": "mail-value",
"mobilePhone": "mobilePhone-value",
"officeLocation": "officeLocation-value",
"preferredLanguage": "preferredLanguage-value",
"surname": "surname-value",
"userPrincipalName": "userPrincipalName-value",
"id": "id-value"
}
]
}
You could then iterate through the list of users and get each of their license details using the licenseDetails method.
Request
GET https://graph.microsoft.com/v1.0/{userid}/licenseDetails
Response
HTTP/1.1 200 OK
Content-type: application/json
Content-length: 389
{
"value": [
{
"servicePlans": [
{
"servicePlanId": "servicePlanId-value",
"servicePlanName": "servicePlanName-value",
"provisioningStatus": "provisioningStatus-value",
"appliesTo": "appliesTo-value"
}
],
"skuId": "skuId-value",
"skuPartNumber": "skuPartNumber-value",
"id": "id-value"
}
]
}

Skype/MS Team REST API not working

I'm creating a bot using REST API. Indeed, I want to send a message from my bot to me as following
I start with 'Authentification'
Request:
curl -k -X POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token -d "grant_type=client_credentials&client_id={app_id}&client_secret={app_password}&scope=https://graph.microsoft.com/.default"
Response:
{
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 0,
"access_token": "<access_token>"
}
Next, I start a new conversation
Request:
POST https://skype.botframework.com/v3/conversations
Authorization: Bearer <access_token>
Content-Type: application/json
{
"bot": {
"id": "standupalice",
"name": "Standup Alice"
},
"isGroup": false,
"members": [
{
"id": "<my bot id>",
"name": "Standup Alice"
},
{
"id": "<my user id>",
"name": "Bao"
}
],
"topicName": "News Alert"
}
NOTE: and are obtained from a callback message sent from Skype app to Standup Alice bot.
Response:
{
"id": "<conversation id>"
}
It's weird since the conversation ID is identical to . Well, now I compose a message to send to me as following
Request:
POST https://skype.botframework.com/v3/conversations/<conversation id>/activities
Authorization: Bearer <access_token>
Content-Type: application/json
{
"type": "message",
"from": {
"id": "<my bot id>",
"name": "Standup Alice"
},
"conversation": {
"id": "<conversation id>",
"name": "News Alert"
},
"recipient": {
"id": "<my user id>",
"name": "Bao"
},
"channelId": "skype",
"text": "My bot's reply"
}
Response (http error 400 - bad request):
{
"error": {
"code": "ServiceError",
"message": "The conversationId <conversation id>and bot <my bot id> doesn't match a known conversation"
}
}
Do you have an idea what's wrong with my requests and parameters?
Note 1: I tried to fire request to https://api.botframework.com/v3/conversations as described in https://docs.botframework.com/en-us/core-concepts/overview/#navtitle, but always receives http error 404 - Resource not found.
Note 2: I just tried the same way for webchat and it works fine, but MS Teams doesn't work (http error 500 - Internal Server Error)
Note 3: my channel settings
Your second API request (the one starting a conversation) should have returned something looking like this:
{
"activityId": "string",
"serviceUrl": "string",
"id": "string"
}
The fact that it didn't suggests to me that that's where the problem is (although full disclosure, I wasn't able to re-create it).
Looking at your "members" array, I see you added the bot. I'm not sure, strictly speaking, that a bot is a member (I think members are human, but I can't find a good definition). So, my best suggestion would be to remove the bot from the members array in that second API call.
Good luck!

Find all users within a thread of gmail API

I am using the gmail API to get recent hangouts messages/threads. But I can't find a way to view the recipient address. The only field in payload.headers is 'From'
code:
curl -H 'Authorization: Bearer **accessToken**' 'https://www.googleapis.com/gmail/v1/users/me/threads/**threadId**?q=is%3Achat'
response:
{
"id": "xxx",
"historyId": "1008967",
"messages": [{
"id": "xxx",
"threadId": "xxx",
"labelIds": [
"CHAT"
],
"snippet": "+Harry Howard",
"historyId": "1008953",
"internalDate": "1481641738948",
"payload": {
"partId": "",
"mimeType": "text/html",
"filename": "",
"headers": [{
"name": "From",
"value": "xxx"
}],
"body": {
"size": 13,
"data": "K0hhcnJ5IEhvd2FyZA=="
}
},
"sizeEstimate": 100
}]
}
In the case of emails, there is a 'To' field ( and sometimes cc etc).
FYI: I am using node-gmail-api npm module but just testing this with curl
Use Users.threads:list to find all users within a thread. See an example here.
HTTP request
GET https://www.googleapis.com/gmail/v1/users/userId/threads
This request requires authorization with at least one of the following scopes
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.metadata
Response
If successful, this method returns a response body with the following structure:
{
"threads": [
users.threads Resource
],
"nextPageToken": string,
"resultSizeEstimate": unsigned integer
}

Mailchimp API v3 add merge field with checkboxes

I need to add checkboxes merge-field with choices to a list.
API key is valid, other requests work and I'm doing such request:
POST https://us12.api.mailchimp.com/3.0/lists/424242/merge-fields
Body: {"name": "provider_accounts", "type": "checkboxes", "options": { "choices": ["BMW", "Audi", "Toyota"]}, "tag": "provider_accounts"}
And I got an error for some reason!
{
"type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title": "Invalid Resource",
"status": 400,
"detail": "The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
"instance": "",
"errors": [
{},
{}
]
}
BTW if I change the type to radio request works and new merge-field is created.

Fail to send data to server using json

I am setting up new payment method in e-shop.
The requirements are:
URL: POST https://payparts2.privatbank.ua/ipp/v2/payment/create
server-server
Headers
Accept: application/json;
Accept-Encoding: UTF-8;
Content-Type: application/json; charset=UTF-8;
Body
{
"storeId": "",
"orderId": "",
"amount": 300.00,
"currency": "980",
"partsCount": 6,
"merchantType": "PP",
"products": [
{
"name": "TV",
"count": 2,
"price": 100.00
},
{
"name": "microwave",
"count": 1,
"price": 200.00
}
],
"responseUrl": "http://shop.com/response",
"redirectUrl": "http://shop.com/redirect",
"signature": ""
}
Here's my code:
http://jsfiddle.net/olga_smelo/hasb5kkr/9/
I've got an error:
FAILContent type 'application/x-www-form-urlencoded;charset=UTF-8' not supporteduk_UA
, but I set "Content type" as "application/json" in ajax
Help me please!

Resources