Missing page content when using generator in Wikipedia API - wikipedia-api

I'm using the categorymembers generator in Wikipedia API to retrieve all pages in a category efficiently, for example:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&generator=categorymembers&rvprop=content&rvslots=*&gcmtitle=Category%3AAirports%20in%20Chad&gcmlimit=5000
(sandbox link)
But some articles are missing content, for instance page id 40376021 "Tchagen Airport":
"40376021": {
"pageid": 40376021,
"ns": 0,
"title": "Tchagen Airport"
},
However, when I retrieve the individual page, it does have content:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&titles=Tchagen%20Airport&formatversion=2&rvprop=content&rvslots=*
(sandbox link)
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 40376021,
"ns": 0,
"title": "Tchagen Airport",
"revisions": [
{
"slots": {
"main": {
"contentmodel": "wikitext",
"contentformat": "text/x-wiki",
"content": "page content here (long, ommited)"
}
}
}
]
}
]
}
}
I don't know what's going on here. It's not a recently created page so it can't be a caching issue. How to ensure that content for all pages can be seen in bulk results?

You only see the content of the first 50 pages.
Thus, it's best practice to set gcmlimit=50 in your request:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&generator=categorymembers&rvprop=content&rvslots=*&gcmtitle=Category%3AAirports%20in%20Chad&gcmlimit=50
In the response, you will see a continue>gcmcontinue value. Use this value in a next request to get the content of another 50 pages:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&generator=categorymembers&rvprop=content&rvslots=*&gcmtitle=Category%3AAirports%20in%20Chad&gcmlimit=50&gcmcontinue=page|482a402a042a3a4c48464c50011001dcc2dc0a|21079773
If the response does not contain a continue value, you know that you retrieved all data.

Related

Shopware 6 Admin Api - Updating existing record through patch method. Not working

shopware 6 admin api patch - why it's failing? I get error "Only single write operations are supported"
Following is api for rule-condition entity in the database, I update it with Id.
For same api get method is working!
url: api/rule-condition/dbb0d904c7c14860a9a94cf26b94eca6
method: patch
json body
[
{
"op": "replace",
"path": "/data/attributes/value/email",
"value": "test#gmail.com"
}
]
response:
{
"errors": [
{
"code": "0",
"status": "400",
"title": "Bad Request",
"detail": "Only single write operations are supported. Please send the entities one by one or use the /sync api endpoint.",
.......
I also tried changing json body to following
{
"data": {
"attributes": {
"value": {
"email": "test#gmail.com"
}
}
} }
Still it's not updating. Can somebody check and let me know what am i missing?
Documentation I followed:
https://shopware.stoplight.io/docs/admin-api/ZG9jOjEyMzA4NTQ5-writing-entities
This website has all apis and example methods. https://swagger.docs.fos.gg/,
rule-condition entity can also be found there.
Btw : I used postman for testing api
You're passing an array of objects in the request body, suggesting you want to update multiple records, but the endpoint only supports updating a single record. The correct payload in your case should look like this:
{
"value": {
"operator": "=",
"email": "test#gmail.com"
}
}
Notice that value is a json field and not only includes a single value. The exact content and the names of the properties of value depend on the type of condition used and usually it also includes the operator used in the condition.

Wikipedia API requests for english page and spanish equivalent. Unable to retrieve spanish JSON for recentchanges

I'm attempting to use the wikipedia API. However, I'm finding that I can only retrieve recent changes for english pages. For example:
https://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rctitle=Battle%20of%20Palma&format=json
returns:
{
"batchcomplete": "",
"query": {
"recentchanges": [{
"type": "edit",
"ns": 0,
"title": "Battle of Palma",
"pageid": 67226819,
"revid": 1061578435,
"old_revid": 1049512969,
"rcid": 1455128770,
"timestamp": "2021-12-22T15:19:02Z"
}]
}
}
However, the same request with the same page in Spanish returns an empty array:
https://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rctitle=Batalla%20de%20Palma&format=json
{"batchcomplete":"","query":{"recentchanges":[]}}
Even though both of the pages exist:
English: https://en.wikipedia.org/wiki/Battle_of_Palma
Spanish: https://es.wikipedia.org/wiki/Batalla_de_Palma
I was using the incorrect API call. The above provides any changes across wikipedia. I needed to use the history call found here: https://www.mediawiki.org/wiki/API:REST_API/Reference#Get_page_history

LinkedIn Share API creates a share but returns error 500

I'm asking this question on SO, since LinkedIn support is officially moved here.
I'm receiving HTTP 500 response from LinkedIn API endpoint while trying to create a share. This happens sporadically, but it is a quite often event last week or two. The weird part is that the share being created successfully.
Please advise. Could it be caused by spiking users activity on social media due to COVID19?
For the reference, here is request body POST-ed to https://api.linkedin.com/v2/shares (real ids are replaced).
{
"owner": "urn:li:organization:111111",
"text": {
"text": "Text text text"
},
"content": {
"contentEntities": [
{
"entity": "urn:li:digitalmediaAsset:111111"
}
],
"shareMediaCategory": "IMAGE"
},
"distribution": {
"linkedInDistributionTarget": {
"connectionsOnly": false,
"visibleToGuest": true
}
}
}
Response:
{
"message": "Internal Server Error",
"status": 500
}

Google custom search api returns 0 results when searchType is image

I'm using Google Custom Search API to search for images. The search result is always 0 when I request for images. I'm following the documentation at the link below:
https://developers.google.com/custom-search/json-api/v1/reference/cse/list
according to the docs, by specifying searchType=images, the api only looks for images.
Here's what my url looks like:
https://www.googleapis.com/customsearch/v1?key=[API_Key]&cx=017576662512468239146:omuauf_lfve&searchType=image&q=cars
and the result looks like below:
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
},
"queries": {
"request": [
{
"title": "Google Custom Search - cars",
"totalResults": "0",
"searchTerms": "cars",
"count": 10,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"cx": "017576662512468239146:omuauf_lfve",
"searchType": "image"
}
]
},
"searchInformation": {
"searchTime": 0.049329,
"formattedSearchTime": "0.05",
"totalResults": "0",
"formattedTotalResults": "0"
}
}
If I remove searchType from the request, I get results back in the form of web pages. What is wrong here?
Your Custom Search Engine might have Image Search disabled. The CSE API returns 0 results if the searchType requested is disabled.
You can enable it by visiting https://cse.google.com/cse/all, opening your search engine, and switching the "Image Search" toggle to ON.
I'm 2 years delayed but i found the solution.
you need to go at your Custom Search Engine Dashboard and turn on the property "Search the entire Web" Or something like that.
When you get that property activated you must be able to see results

Instagram API getting error on UTF-8 characters (tested on /tags/{TAGNAME}/media/recent)

Shamelessly stolen from this ( https://groups.google.com/forum/#!topic/instagram-api-developers/tRfU444ZyhU ) thread as I have the exact same issue and hoping for better responses here.
Long story short, a few hours ago this was working, now it isn't.
The test platform can be found at both from my website and https://apigee.com/console/instagram
Sending https://api.instagram.com/v1/tags/türkiye/media/recent (careful with the "ü")
result: {
"meta": {
"error_type": "OAuthParameterException",
"code": 400,
"error_message": ""client_id" or "access_token" URL parameter missing. This OAuth request requires either a "client_id" or "access_token" URL parameter."
}
}
Sending https://api.instagram.com/v1/tags/turkiye/media/recent (now with "u")
result: {
"pagination": {},
"meta": {},
"data": [
{},
{},
{},
{},.. .. .. ... and so on
Sending https://api.instagram.com/v1/tags/türkiye/media/recent?client_id=7176aa6ef2fd47fd9cb373a5354bd30f ("ü" again and this time manually attached client_id)
result: {
"meta": {
"code": 200
},
"data": {
"media_count": 1471127,
"name": "t"
}
}
This time I'm getting the name as "t". It seems the query is broken just before the "ü" letter which is UTF-8 (Turkish if needed).
This is a bug on Instagram-side. There's an open discussion on Instagram Developers Google group. Although, from what I've seen in my application, the bug now resolve.