Square V1 api request not working as per API docs - square-connect

We are experiencing errors with few of Square APIs, it was working a week back, now which is not working as per the documentation, anything changed recently related to square, not able to find out in news : https://docs.connect.squareup.com/api/connect/v1/?q=employee#navsection-roles & https://docs.connect.squareup.com/api/connect/v1/?q=employee#navsection-employees.
Request/Response in question.
Ex 1: With Valid role_ids too it's failing, which used to work 3-4 days back.
POST https://connect.squareup.com/v1/me/employees HTTP/1.1
Host: connect.squareup.com
Accept: */*
Authorization: Bearer *****************************
Content-Type: application/json
Content-Length: 120
{
"first_name": "FIRST_NAME_TEST_SP",
"last_name": "LAST_NAME_TEST_SP",
"role_ids": ["T6u3cmJnH7eZbAlvPfql"]
}
--
HTTP/1.1 400 Bad Request
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Request-Id: V6fCtNEkQB2p9lSpswcS
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Link
Content-Type: application/json; charset=utf-8
Vary: Accept-Encoding
X-Response-Time: 296ms
Date: Fri, 28 Jul 2017 07:51:07 GMT
Keep-Alive: timeout=60
Strict-Transport-Security: max-age=631152000
content-length: 74
{"type":"bad_request","message":"role_ids [T6u3cmJnH7eZbAlvPfql] invalid"}
Ex 2: As per API docs, role_ids is optional, but without it its failing.
POST https://connect.squareup.com/v1/me/employees HTTP/1.1
Host: connect.squareup.com
Accept: */*
Authorization: Bearer *****************************
Content-Type: application/json
Content-Length: 87
{
"first_name": "FIRST_NAME_TEST_MIN_SP",
"last_name": "LAST_NAME_TEST_MIN_SP"
}
--
HTTP/1.1 400 Bad Request
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Request-Id: fjrobTpoQ/SqjGLjYY+f
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Link
Content-Type: application/json; charset=utf-8
Vary: Accept-Encoding
X-Response-Time: 286ms
Date: Fri, 28 Jul 2017 07:51:08 GMT
Keep-Alive: timeout=60
Strict-Transport-Security: max-age=631152000
content-length: 54
{"type":"bad_request","message":"role_ids [] invalid"}
Ex 3: Permission is mandatory for creating roles, but now it's passing.
POST https://connect.squareup.com/v1/me/roles HTTP/1.1
Host: connect.squareup.com
Accept: */*
Authorization: Bearer *****************************
Content-Type: application/json
Content-Length: 71
{
"name": "TEST_NAME_EMPTYPERMISSIONMIN_SP",
"permissions": []
}
--
HTTP/1.1 200 OK
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Request-Id: zPvmsdjdQr+KolWM85K/
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Link
Content-Type: application/json; charset=utf-8
Vary: Accept-Encoding
X-Response-Time: 245ms
Date: Fri, 28 Jul 2017 07:51:09 GMT
Keep-Alive: timeout=60
Strict-Transport-Security: max-age=631152000
content-length: 176
{"permissions":[],"id":"pNxPulcufnUpifjqnR0Y","name":"TEST_NAME_EMPTYPERMISSIONMIN_SP","is_owner":false,"updated_at":"2017-07-28T07:51:09Z","created_at":"2017-07-28T07:51:09Z"}

Related

ms bot service, Is it possible to update both text and attachments? Encounter with `Activity resulted into multiple skype activities`

I have a demand to update past chat items which is send to bot.
I use the following API to update activity.
https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#update-activity
I successfully updated the message when I request like this.
~~~ REQUEST ~~~
PUT /jp/v3/conversations/conversationID/activities/activityID HTTP/1.1
HOST : smba.trafficmanager.net
HEADERS:
Accept: application/json;charset=utf-8
Authorization: Bearer Token
Content-Type: application/json;charset=utf-8
User-Agent: go-resty/2.3.0 (https://github.com/go-resty/resty)
BODY :
{
"text": "lllllll\u003cp\u003e\u003cbr\u003e\u003c/p\u003e\\n\u003cdiv\u003e\u003cimg width=\"386\" height=\"476\" src=\"https://host.jp.ngrok.io/api/v1/images?item_id=01TPIDETFC2MITU7PJFJHYUZEZYJBOMWCL\u0026group_id=f64dd886-4edf-4b23-8f51-c6720042807d\u0026token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJib3RfaWQiOjEsImdyb3VwX2lkIjoiZjY0ZGQ4ODYtNGVkZi00YjIzLThmNTEtYzY3MjAwNDI4MDdkIiwiaXRlbV9pZCI6IjAxVFBJREVURkMyTUlUVTdQSkZKSFlVWkVaWUpCT01XQ0wiLCJhdWQiOiJ3b3JrcGxhY2UuYmVkb3JlLmpwIiwiaWF0IjoxNjY0MzQzNDg2LCJpc3MiOiJ3b3JrcGxhY2UuYmVkb3JlLmpwIiwibmJmIjoxNjY0MzQzNDg2fQ.MZKEurQeBqP71iEcdxuiG342ZDvhMZ-QxqYnJYvbhmM\"/\u003e\u003c/div\u003e\\n\u003cp\u003e\u003cbr\u003e\u003c/p\u003e",
"type": "message",
"id": "1664769144846"
}
------------------------------------------------------------------------------
~~~ RESPONSE ~~~
STATUS : 200 OK
PROTO : HTTP/1.1
RECEIVED AT : 2022-10-03T15:30:50.642248+09:00
TIME DURATION: 434.921ms
HEADERS :
Content-Length: 22
Content-Type: application/json; charset=utf-8
Date: Mon, 03 Oct 2022 06:30:49 GMT
Ms-Cv: QxMPXxpyPk2IcBQOtkyErA.0
Server: Microsoft-HTTPAPI/2.0
BODY :
{
"id": "1664769144846"
}
And I failed when I request like this.
2022/10/03 15:32:45.241320 DEBUG RESTY
==============================================================================
~~~ REQUEST ~~~
PUT /jp/v3/conversations/conversationID/activities/activityID HTTP/1.1
HOST : smba.trafficmanager.net
HEADERS:
Accept: application/json;charset=utf-8
Authorization: Bearer Token
Content-Type: application/json;charset=utf-8
User-Agent: go-resty/2.3.0 (https://github.com/go-resty/resty)
BODY :
{
"text": "lllllll\u003cp\u003e\u003cbr\u003e\u003c/p\u003e\\n\u003cdiv\u003e\u003cimg width=\"386\" height=\"476\" src=\"https://host.jp.ngrok.io/api/v1/images?item_id=01TPIDETFC2MITU7PJFJHYUZEZYJBOMWCL\u0026group_id=f64dd886-4edf-4b23-8f51-c6720042807d\u0026token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJib3RfaWQiOjEsImdyb3VwX2lkIjoiZjY0ZGQ4ODYtNGVkZi00YjIzLThmNTEtYzY3MjAwNDI4MDdkIiwiaXRlbV9pZCI6IjAxVFBJREVURkMyTUlUVTdQSkZKSFlVWkVaWUpCT01XQ0wiLCJhdWQiOiJ3b3JrcGxhY2UuYmVkb3JlLmpwIiwiaWF0IjoxNjY0MzQzNDg2LCJpc3MiOiJ3b3JrcGxhY2UuYmVkb3JlLmpwIiwibmJmIjoxNjY0MzQzNDg2fQ.MZKEurQeBqP71iEcdxuiG342ZDvhMZ-QxqYnJYvbhmM\"/\u003e\u003c/div\u003e\\n\u003cp\u003e\u003cbr\u003e\u003c/p\u003e",
"type": "message",
"id": "1664769144846",
"attachments": [
{
"contentType": "image/png",
"contentUrl": "https://via.placeholder.com/750",
"name": "placeholder"
}
]
}
------------------------------------------------------------------------------
~~~ RESPONSE ~~~
STATUS : 400 Bad Request
PROTO : HTTP/1.1
RECEIVED AT : 2022-10-03T15:32:45.241272+09:00
TIME DURATION: 84.414125ms
HEADERS :
Content-Length: 91
Content-Type: application/json; charset=utf-8
Date: Mon, 03 Oct 2022 06:32:44 GMT
Ms-Cv: kn6QMv/UH0iJhMXfL0s1HA.0
Server: Microsoft-HTTPAPI/2.0
BODY :
{
"error": {
"code": "BadSyntax",
"message": "Activity resulted into multiple skype activities"
}
}
It looks that it is impossible to update text and attachments at the same time. It is necessary for us to update both text and attachments within one request for sending only attachments will erase text info.
Does anyone know the reason about **Activity resulted into multiple skype activities**?

Consul:Cannot list event with tag

If I fire event with a tag and service, I cannot list the events
PUT http://127.0.0.1:8500/v1/event/fire/eee?tag=t&&service=abc
Content-Type: application/json
{
"ask":"how much"
}
It's ok:
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Accept-Encoding
X-Consul-Default-Acl-Policy: allow
Date: Tue, 08 Mar 2022 12:28:13 GMT
Content-Length: 247
Connection: close
{
"ID": "d1b228a8-8d04-d837-c0d0-6b853ec6e7e9",
"Name": "eee",
"Payload": "ew0KICAgICJhc2siOiJob3cgbXVjaCINCn0NCg0KDQoNCg0KR0VUIGh0dHA6Ly8xMjcuMC4wLjE6ODUwMC92MS9ldmVudC9saXN0",
"NodeFilter": "",
"ServiceFilter": "abc",
"TagFilter": "t",
"Version": 1,
"LTime": 0
}
However I cannot list the event.
GET http://127.0.0.1:8500/v1/event/list
It returns
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Accept-Encoding
X-Consul-Default-Acl-Policy: allow
X-Consul-Index: 1
Date: Tue, 08 Mar 2022 12:23:29 GMT
Content-Length: 2
Connection: close
[]
If I fire event without tag and service, everything will be ok. So i want to know what's the problem?
I checked the code and found the answer, the service must be registered with the same tag, otherwise the event will not generate, and the list query returns empty later.

How to create a Git repository through projects.repos.create api?

The question is very simple but I’m only getting errors :
POST https://sourcerepo.googleapis.com/v1/projects/<example>/repos?key={YOUR_API_KEY}
{
"name": ">repos>"
}
Which gives :
HTTP/400
cache-control: private
content-encoding: gzip
content-length: 251
content-type: application/json; charset=UTF-8
date: Thu, 15 Feb 2018 22:46:47 GMT
server: ESF
vary: Origin, X-Origin, Referer
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.LocalizedMessage",
"locale": "en-US",
"message": "Invalid repo name: repos. Must be of the form projects/<project>/repos/<repo>"
}
]
}
}
Where example is an existing project and repos is the repository name I want to create.
What am I missing ? I failed to find an example of working code.
This is the most important part of the error:
{
....
"message": "Invalid repo name: repos. Must be of the form projects/<project>/repos/<repo>"
....
}
Which tells you that the format of the name field is not correct. Let's say you have this settings:
Project: your-project-name
Repo: desired-repo-name
Then your request body must be:
{
"name": "projects/your-project-name/repos/desired-repo-name"
}
After executing you'll receive the confirmation:
200
cache-control: private
content-encoding: gzip
content-length: 77
content-type: application/json; charset=UTF-8
date: Wed, 21 Feb 2018 11:12:46 GMT
server: ESF
vary: Origin, X-Origin, Referer
{
"name": "projects/your-project-name/repos/desired-repo-name"
}

Google Batch API, multiple authorization headers

Looking for some help with the Google Batch API,
got two valid access tokens for two different accounts under the same domain/organization and want to batch two calls, each with it's own authorization header.
If I'm reading into it correctly, it should be possible according to the API docs:
The HTTP headers for the outer batch request, except for the Content- headers such as Content-Type, apply to every request in the batch. If you specify a given HTTP header in both the outer request and an individual call, then the individual call header's value overrides the outer batch request header's value. The headers for an individual call apply only to that call.
For example, if you provide an Authorization header for a specific call, then that header applies only to that call. If you provide an Authorization header for the outer request, then that header applies to all of the individual calls unless they override it with Authorization headers of their own.
Testing it out with Postman (POST https://www.googleapis.com/batch)
when the request has no authentication header but the inner request has valid authentication headers:
--batch_foobarbaz
Authorization:Bearer <accesstoken1>
Content-Type: application/http Content-ID: one
GET /gmail/v1/users/me/profile
--batch_foobarbaz
Authorization:Bearer <accesstoken2>
Content-Type: application/http
Content-ID: two
GET /gmail/v1/users/me/profile
--batch_foobarbaz--
I get as a response "Login Required" for both of the requests:
--batch_x-oYQ5TohrI_AAd7PA4mQcg
Content-Type: application/http
Content-ID: response-one
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/"
Content-Type: application/json; charset=UTF-8
Date: Sun, 12 Nov 2017 12:28:55 GMT
Expires: Sun, 12 Nov 2017 12:28:55 GMT
Cache-Control: private, max-age=0
Content-Length: 238
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
--batch_x-oYQ5TohrI_AAd7PA4mQcg
Content-Type: application/http
Content-ID: response-two
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/"
Content-Type: application/json; charset=UTF-8
Date: Sun, 12 Nov 2017 12:28:55 GMT
Expires: Sun, 12 Nov 2017 12:28:55 GMT
Cache-Control: private, max-age=0
Content-Length: 238
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
--batch_x-oYQ5TohrI_AAd7PA4mQcg--
As Google commands me, on my second attempt I put an authentication header on the request with "accesstoken1" hoping the inner requests headers would override it:
--batch_foobarbaz
Content-Type: application/http
Content-ID: one
Authorization: Bearer <accesstoken1>
GET /gmail/v1/users/me/profile
--batch_foobarbaz
Content-Type: application/http
Content-ID: two
Authorization: Bearer <accesstoken2>
GET /gmail/v1/users/me/profile
--batch_foobarbaz--
However, the inner Authorization headers gets ignored and I get the same response for both inner requests:
--batch_acwJ2jJl7Vk_AAwDDvF7GqQ
Content-Type: application/http
Content-ID: response-one
HTTP/1.1 200 OK
ETag: "Sa8s0oAMlJSbjHHTmOHVq5KXvZM/ij85zVL5i9x1u7LOtgNBEd-PGZY"
Content-Type: application/json; charset=UTF-8
Date: Sun, 12 Nov 2017 12:52:16 GMT
Expires: Sun, 12 Nov 2017 12:52:16 GMT
Cache-Control: private, max-age=0
Content-Length: 108
{
"emailAddress": "user1#whatever.com",
"messagesTotal": 16,
"threadsTotal": 13,
"historyId": "7294"
}
--batch_acwJ2jJl7Vk_AAwDDvF7GqQ
Content-Type: application/http
Content-ID: response-two
HTTP/1.1 200 OK
ETag: "Sa8s0oAMlJSbjHHTmOHVq5KXvZM/ij85zVL5i9x1u7LOtgNBEd-PGZY"
Content-Type: application/json; charset=UTF-8
Date: Sun, 12 Nov 2017 12:52:16 GMT
Expires: Sun, 12 Nov 2017 12:52:16 GMT
Cache-Control: private, max-age=0
Content-Length: 108
{
"emailAddress": "user1#whatever.com",
"messagesTotal": 16,
"threadsTotal": 13,
"historyId": "7294"
}
--batch_acwJ2jJl7Vk_AAwDDvF7GqQ--
If anyone can make sense of this I'd be forever grateful
Thanks!
I guess your inner authentication headers would come after the GET/POST requests.
For example
GET https://www.googleapis.com/calendar/v3/calendars/primary/events
Authorization:Bearer XXXXXXXXXXXXXXXXXXXX
instead of
Authorization:Bearer XXXXXXXXXXXXXXXXXXXX
GET https://www.googleapis.com/calendar/v3/calendars/primary/events.
In your example, it would be
--batch_foobarbaz
Content-Type: application/http
Content-ID: one
GET /gmail/v1/users/me/profile
Authorization: Bearer
This worked for me. Let me know if this is working for you.

Google API gmail errors 403 and 401

Trying to fetch mail from a Gmail account.
I click the "Send the request" button, and this is what I get:
(I have changed the authorization code)
GET /gmail/v1/users/{userId}/messages HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: Bearer ya29.nwDDjrH18VYHzBaFoaEDQltoenRUlFRxzMh94MGKekMSD8sBWvjqS2TF
HTTP/1.1 401 Unauthorized
Content-length: 249
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Expires: Wed, 15 Oct 2014 21:28:28 GMT
Vary: Origin,Referer,X-Origin
Server: GSE
Cache-control: private, max-age=0
Date: Wed, 15 Oct 2014 21:28:28 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json; charset=UTF-8
Www-authenticate: Bearer realm="https://accounts.google.com/AuthSubRequest", error=invalid_token
{
"error": {
"code": 401,
"message": "Invalid Credentials",
"errors": [
{
"locationType": "header",
"domain": "global",
"message": "Invalid Credentials",
"reason": "authError",
"location": "Authorization"
}
]
}
}
This is where I click the "Send the request" button.1

Resources