loopback API GET no usable index for cloudant database - loopbackjs

Using the Loopback API explorer GET try this button with and without a filter, I am getting result no_usable_index:
{
"error": {
"statusCode": 400,
"name": "Error",
"message": "No index exists for this sort, try indexing by the sort fields.",
"error": "no_usable_index",
"reason": "No index exists for this sort, try indexing by the sort fields.",
"scope": "couch",
"request": {
"method": "post",
"headers": {
"content-type": "application/json",
"accept": "application/json"
},
"uri": "https://XXXXXX:XXXXXX#long-instance-id-number-bluemix.cloudant.com/aac_001_dev_db/_find",
"body": "{\"selector\":{\"loopback__model__name\":\"Center\"},\"use_index\":[\"lb-index-ddoc-Center\",\"lb-index-Center\"],\"sort\":[{\"id:string\":\"asc\"}]}"
},
"headers": {
"x-frame-options": "DENY",
"x-couch-request-id": "658ac2fdf8",
"date": "Tue, 06 Mar 2018 17:45:29 GMT",
"content-type": "application/json",
"cache-control": "must-revalidate",
"strict-transport-security": "max-age=31536000",
"x-content-type-options": "nosniff",
"x-cloudant-request-class": "query",
"x-cloudant-backend": "bm-cc-us-south-02",
"via": "1.1 lb1.bm-cc-us-south-02 (Glum/1.50.1)",
"statusCode": 400,
"uri": "https://XXXXXX:XXXXXX#long-instance-id-number-bluemix.cloudant.com/aac_001_dev_db/_find"
},
"errid": "non_200",
"description": "couch returned 400",
"stack": "Error: No index exists for this sort, try indexing by the sort fields.\n at Request._callback (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/cloudant-nano/lib/nano.js:248:15)\n at Request.self.callback (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/request/request.js:186:22)\n at emitTwo (events.js:106:13)\n at Request.emit (events.js:191:7)\n at Request.<anonymous> (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/request/request.js:1163:10)\n at emitOne (events.js:96:13)\n at Request.emit (events.js:188:7)\n at IncomingMessage.<anonymous> (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/request/request.js:1085:12)\n at IncomingMessage.g (events.js:292:16)\n at emitNone (events.js:91:20)\n at IncomingMessage.emit (events.js:185:7)\n at endReadableNT (_stream_readable.js:974:12)\n at _combinedTickCallback (internal/process/next_tick.js:80:11)\n at process._tickCallback (internal/process/next_tick.js:104:9)"
}
}
So I tried searching the lb3 documentation and found a cloudant-connector loopback.io / doc / en / lb3 / Cloudant-connector.html#index that describes the index feature as "To be updated". Hmmm, it is listed as a feature backlog.
Then I found [:link:][2] to the Model-definition-JSON-file which describes manually adding an indexes property. I tried:
// common -> models -> center.json
"indexes": {
"name_index": {"name": 1}
}, ...
I also tried the suggestion: "You can specify indexes at the model property level too, for example:"
"properties": {
"name": {
"type": "string",
"required": true,
"index": true // added this (but without the comment :)
}, ...
Alas, none of these attempts worked. I am still getting the error.
I have watched several off topic youtube videos of Loopback with MongoDB, but it is curious that there is not much available showing exactly how to get the Loopback-connector to work with Cloudant.
At this point I just want:
to GET the two test documents that have been POSTed using the the API explorer.
to know if these cloudant-connector GET methods work at all with lb version 3.
I added a mongodb datasource from the command line and edited the model-config.json file datsource parameter to point to the mongodb database, then performed a similar test. Added two documents with the POST button, then clicked try this with the GET button. It returns the two documents that were posted, just like in the youtube video tutorials.
Update with more clues
In the Cloudant dashboard query page there is a selector. If I make an errant change to the selector, Cloudant returns the error "no_usable_index". This means that the error message is not from Loopback, it is from Cloudant, but passed through Loopback.
Although the Loopback explorer has the same visual look and feel for both the mongo-connector and cloudant-connector; the url (REST) interface to the databases clearly must be different. I assumed that the POST, GET sequence of button clicks in the explorer that works to connect with Mongodb would work with Cloudant. It does not. Cloudant requires that a design document be available in the database to define valid queries.
I know for sure the database is accessible from the command line with:
$ curl $CLOUDANT_URL/$CLOUDANT_DATABASE
and with a design doc defined within the database
$ curl $CLOUDANT_URL/$CLOUDANT_DATABASE/_design/$DDOC_MEDICAL_CENTERS/_view/$VIEW_MEDICAL_CENTERS_TRUE

After much troubleshooting in the old version I found that the error went away when I changed
FROM loopback-connector-cloudant#1.2.5 3-Aug 2017
TO loopback-connector-cloudant#2.0.5 23-Mar 2018
by updating the package.json and running an npm update

Related

how to get facebook page creation date using facebook api

my try : https://graph.facebook.com/v12.0/{mypageid}?fields={fieldname_of_type_PageStartDate}
Could not get any response when using this api and i am also confused about {fieldname_of_type_PageStartDate} parameter value. i tried day,month,year value according to https://developers.facebook.com/docs/graph-api/reference/page-start-date/ this fb website but it didn't work.
please suggest any way to get facenook page creation date using api.
The documentation is a bit misleading, because what that page does not tell you on its own, is that those fields are part of the start_info property of the page - so you have to query that one.
https://graph.facebook.com/v12.0/pageid?fields=start_info
This will give you a structure of the following format:
"data": [
{
"name": "...",
"start_info": {
"type": "Started",
"date": {
"year": 2021,
"month": 11,
"day": 29
}
},
"id": "1234567890"
},
Not all sub-fields will always be set; you might for example encounter types Founded with only a year set, or Unspecified with no date info at all.
Note that this is not the actual page creation date; but the "start date" of the entity represented by the page. So it must be explicitly set in the page settings, otherwise this field will be empty.

Google my business not fetching reviews correctly

I'm currently using Google's api for fetching reviews of a Google My Business Account. We do this for our clients, which have to enable oauth for us, so we can have an access token and a refresh token.
The response we get, has the following structure:
url: https://mybusiness.googleapis.com/v4/accounts/{account_id}/locations/{location_id}/reviews
{
"reviews": [
{
"reviewId": "some-id,
"reviewer": {
"profilePhotoUrl": "some-url",
"displayName": "Some Sample Name"
},
"starRating": "FOUR",
"comment": "Some long comment left by the user.",
"createTime": "2021-02-15T14:35:19.252Z",
"updateTime": "2021-02-15T14:35:19.252Z",
"reviewReply": {
"comment": "Some long reply by the business.",
"updateTime": "2021-03-04T16:49:32.973Z"
},
"name": "accounts/{account_id}/locations/{location_id}/reviews/{review_id}"
},
...
],
"averageRating": 4.5,
"totalReviewCount": 1312,
"nextPageToken": "some-page-token"
}
The problem is, for some set of clients, we are getting just an empty object (literally, we are receiving {} as the response body). We are not sure why this is happening, since we are able to see reviews on the client's web site, and we are not getting any error. We've refreshed tokens and refreshed tokens without any success.
I've tried posting a support ticket with GCP in order to get some guidance, but it seems that you don't get any help in this kind of issues if you don't have the right support plan.
Anyhow, any help on this issue (why is happening? can it be fixed? is it a setup problem? etc.) is very much appreciated.

Docusign Create Envelope ENVELOPE_IS_INCOMPLETE using templateId

The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line.
I am trying to create an envelope using the REST Api from docusign and got this error. This was working a few weeks ago and now, I suddenly got this error. Below is my json body for the request.
{
"status": "sent",
"emailSubject": "Company Contract: Signature Required",
"templateId": "310439de-819e-404b-90d6-a468bc0e4e12",
"templateRoles": [
{
"email": "sample1#gmail.com",
"name": "Buyer Buy",
"roleName": "BUYER_PROFILE"
},
{
"email": "sample#gmail.com",
"name": "First Floor",
"roleName": "SELLER_PROFILE"
}
]
}
I also tried this request via postman and I still have the same error. I hope anyone can help. Thanks
It seems you have not added any DS Tabs for all the signers in your DS template "templateId": "310439de-819e-404b-90d6-a468bc0e4e12". A signer in an envelope always needs at least on DS Tab on the document. So update your template to add atleast one tab for every Signer role and it should fix your error.

Facebook API process shared object [duplicate]

I just tried through the Graph API Explorer with this path /v2.4/10153513872748291 and I've got this result:
{
"error": {
"message": "(#12) singular links API is deprecated for versions v2.4 and higher",
"type": "OAuthException",
"code": 12
}
}
But https://developers.facebook.com/docs/reference/api/post/ doesn't say anything about deprecation.
I'm not sure if I miss something, or there's another way to get info about an individual post.
Edit: v2.3 works, but v2.4 is the latest one.
Looks like you now need to the combination of the id of the user or page that made the post (or whose wall it is on), an underscore, and then the post id.
For your example post, 10153513872748291, that is made by a page Drama-addict, that has the id 141108613290 – so 141108613290_10153513872748291 will work.
And so does 788239567865981_10153513872748291, because 788239567865981 is the id of the user making the post.
Firstput userId underscore add postId /Likes to check Like status in facebook
userId_post_Id/Likes to fetch Likes Records
userId_post_Id/Comments to fetch Comments Records
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=303261006522998_751199848395776%2FLikes&version=v2.9
**In this link Right side Get Token indide GetAccessToken to select Permission**
303261006522998_751199848395776/Likes
303261006522998_751199848395776/Comments
{
"data": [
{
"id": "124778301449917",
"name": "Manisha Gera"
},
{
"id": "1680577265523548",
"name": "Rubi Sharma"
}
],
"paging": {
"cursors": {
"before": "MTI0Nzc4MzAxNDQ5OTE3",
"after": "MTY4MDU3NzI2NTUyMzU0OAZDZD"
}
}
}

Facebook Objects API Queries o

I have asked some old questions previously but those were quite misleading. So I decided to delete them and creating this one.
My object has a custom property named say it is portal content. In the Facebook Graph API Explorer data related to this object shown like;
{
"created_time": "2015-11-26T08:42:26+0000",
"title": "Title",
"type": "ns:type",
"data": {
"portalcontent": "portalcontent"
},
"id": "12515125125"
},
{
"created_time": "2015-11-26T08:04:09+0000",
"title": "Title2",
"type": "ns:type",
"id": "412512512512"
},
{
"created_time": "2015-11-25T12:56:03+0000",
"title": "Title3",
"type": "ns:type",
"id": "234124124124"
}
I am trying to query this data using Facebook graph api. But can not fetch just based on the portal content custom property.
So far I tried;
appid/objects?pretty=0&type=ns:type&limit=100&portalcontent=portalcontent
to do so. But it is still fetching all objects.
PS: please pm or comment on question for why you are downvoting it. Provide what else you need that I must put on the question. Downvoting for no reason getting people annoyed.
There's currently no way to filter results other than those described on the respective endpoint's docs.
See
https://developers.facebook.com/docs/graph-api/reference/application/objects/
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.5