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**?
Related
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.
I use es 6.3.2.I want to fetch documents using scroll.Use postman to test:
first,I create an index:
PUT /person4 HTTP/1.1
Host: localhost:9200
Cache-Control: no-cache
Postman-Token: 6d98c502-d37b-4798-adc8-2fb1f31f228f
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
then insert some documents:
POST /person4/type1 HTTP/1.1
Host: localhost:9200
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 70f2167e-280f-444c-b588-d034c8a55a5c
{
"lastname":"alex"
}
repeat this post for many times.
follow this instruction:web
Then use scroll api first time:
POST /person4/_search?scroll=1s HTTP/1.1
Host: localhost:9200
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 6d92fbb8-c861-434f-bf31-3023ff1fb282
{
"size": 1,
"query": {
"match" : {
"lastname" : "alex"
}
}
}
Then got 1 document and the scroll id
Finally,second fetch:
POST /person4/_search/scroll HTTP/1.1
Host: localhost:9200
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 14238262-6125-4f60-8025-d0d2854b8dd6
{
"scroll" : "1s",
"scroll_id" : "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAABIFklhQmdpTWVOUTVxbkFTM1l6U1dpRHcAAAAAAAAAShZJYUJnaU1lTlE1cW5BUzNZelNXaUR3AAAAAAAAAEkWSWFCZ2lNZU5RNXFuQVMzWXpTV2lEdwAAAAAAAABHFklhQmdpTWVOUTVxbkFTM1l6U1dpRHcAAAAAAAAASxZJYUJnaU1lTlE1cW5BUzNZelNXaUR3"
}
Then got an error:
{
"error": {
"root_cause": [
{
"type": "invalid_type_name_exception",
"reason": "Document mapping type name can't start with '_', found: [_search]"
}
],
"type": "invalid_type_name_exception",
"reason": "Document mapping type name can't start with '_', found: [_search]"
},
"status": 400
}
So I have to add the type:
POST /person4/_search/type1/scroll HTTP/1.1
Host: localhost:9200
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 43c8052f-76c9-41b9-a0a6-637eb5fee30b
{
"scroll" : "1s",
"scroll_id" : "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAABIFklhQmdpTWVOUTVxbkFTM1l6U1dpRHcAAAAAAAAAShZJYUJnaU1lTlE1cW5BUzNZelNXaUR3AAAAAAAAAEkWSWFCZ2lNZU5RNXFuQVMzWXpTV2lEdwAAAAAAAABHFklhQmdpTWVOUTVxbkFTM1l6U1dpRHcAAAAAAAAASxZJYUJnaU1lTlE1cW5BUzNZelNXaUR3"
}
Then I got an new error:
{
"error": "no handler found for uri [/person4/_search/type1/scroll] and method [POST]"
}
So how to fetch more document?Can only fetch for one time?
The problem is your second fetch has index name in the request URL. The URL should not include the index or type name — these are specified in the original search request instead.
Instead of this:
POST /person4/_search/scroll HTTP/1.1
Host: localhost:9200
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 14238262-6125-4f60-8025-d0d2854b8dd6
{
"scroll" : "1s",
"scroll_id" : "Whatever scroll id you've got"
}
Use this:
POST /_search/scroll HTTP/1.1
Host: localhost:9200
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 14238262-6125-4f60-8025-d0d2854b8dd6
{
"scroll" : "1s",
"scroll_id" : "Whatever scroll id you've got"
}
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"
}
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.
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