Language detection always returns 1 result - microsoft-cognitive

I'm having troubles with getting Language Detection to work. According to the documentation on Microsoft's website I should be able to get multiple languages when the service is not sure about which language the input string was. However, I am always receiving only one language. In my example below I used "Hallo" which is "Hello" in both German and Dutch. Also with other words like "Bier" which is "Beer" in German and Dutch, the service gives only one result, despite the numberOfLanguages Query parameter value of 5.
Am I missing something?
Is the service malfunctioning?
Can someone provide an example which delivers multiple languages as a result?
Thank you for all your help.
Request:
POST https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/languages?numberOfLanguagesToDetect=5 HTTP/1.1
Content-Type: application/json
Host: westus.api.cognitive.microsoft.com
Ocp-Apim-Subscription-Key: ••••••••••••••••••••••••••••••••
{
"documents": [
{
"id": "Test",
"text": "Hallo"
}
]
}
With this response:
Transfer-Encoding: chunked
x-ms-transaction-count: 0
x-aml-ta-request-id: 4bb2e01e-59a1-4f66-bb31-8ca2c32d262b
X-Content-Type-Options: nosniff
apim-request-id: 65a8d5f5-1394-43cf-89e1-83d7188cb81a
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Date: Tue, 25 Apr 2017 15:18:34 GMT
Content-Type: application/json; charset=utf-8
{
"documents": [
{
"id": "Test",
"detectedLanguages": [
{
"name": "German",
"iso6391Name": "de",
"score": 1.0
}
]
}
],
"errors": []
}

The documentation has been updated to explain this.
numberOfLanguagesToDetect: Format - int32. (Optional. Deprecated) Number of languages to detect. Set to 1 by default. Irrespective of
the value, the language with the highest score is returned.

Related

Azure Cosmos Table API Rest API $filter InvalidInput

I am trying to query a Cosmosdb with a Table API with Postman and use OData.
I have a query which works for $top and $select - but returns Invalid Input when I try a filter.
so for the query.
https://{{databaseAccount}}.table.cosmos.azure.com:443/Rdm()?$filter=PartitionKey eq '726'
I get returned
{
"odata.error": {
"code": "InvalidInput",
"message": {
"lang": "en-us",
"value": "Request url is invalid.\r\nActivityId: 3cf6769d-fe56-40ca-832d-305820ef78e1, documentdb-dotnet-sdk/2.14.0 Host/64-bit MicrosoftWindowsNT/10.0.19041.0\nRequestID:3cf6769d-fe56-40ca-832d-305820ef78e1\n"
}
}
}
Though the following will return me results:
https://{{databaseAccount}}.table.cosmos.azure.com:443/Rdm()?$top=1&$select=PartitionKey
Gives:
{
"value": [
{
"odata.etag": "W/\"datetime'2022-01-01T14%3A07%3A54.8052493Z'\"",
"PartitionKey": "8"
}
]
}
Is there some weird little header that is required to do filtering?
Clearly Authorisation is working, otherwise headers sent are:-
Accept: application/json
x-ms-version: 2021-06-08
x-ms-date: Fri, 06 May 2022 17:14:30 GMT
Authorization: SharedKey {{databaseAccount}}:gargbagebutitdoesappeeartotherwisework
User-Agent: PostmanRuntime/7.29.0
Cache-Control: no-cache
Postman-Token: 0e09a9e8-210d-4b6f-a258-efe6963bff39
Host: {{databaseAccount}}.table.cosmos.azure.com:443
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
The signature is composed of:
verb + \n + \n + \n + dateUtc + \n + /{{databaseAccount}}/{{table}}
where table in this case = Rdm()
Turns out I needed to add the header - MaxDataServiceVersion: 3.0;NetFx
Eventually found the answer in GitHub https://github.com/Azure/azure-sdk-for-go/issues/1020
It's also quite clearly stated in their documentation - doh.
https://learn.microsoft.com/en-us/rest/api/storageservices/setting-the-odata-data-service-version-headers
When you call one of these operations, you must specify the OData data
service version, using one of the following request headers:
MaxDataServiceVersion, to specify the maximum data service version
DataServiceVersion, to specify the exact data service version
If both headers are present, precedence is given to
MaxDataServiceVersion

Unable to decode form field data in karate framework [duplicate]

This question already has an answer here:
Karate: Query Param values are getting encoded
(1 answer)
Closed 1 year ago.
I have recently learnt about Karate and it's awesome experience working on this.
I'm stuck at one problem and looked out for a solution from various websites but it didn't help
Scenario:
Given url "https://test.payu.in/_payment"
And form field surl = '/payu/web-response/17703721?appVersion=null&clientId=web-client/1.0'
When method POST
Then status 302
When we hit the above request the form field value is getting encoded as 'surl=%2Fpayu%2Fweb-response%2F17703721%3FappVersion%3Dnull%26clientId%3Dweb-client%2F1.0'
due to this request is failing
If you can provide me the solution it would be really helpfull
Solutions tried :
java.net.URLDecoder.decode('/payu/web-response/17703721?appVersion=null&clientId=web-client/1.0', 'UTF-8')
But no luck
Karate is doing the right thing. You can see for yourself using this 3-line Karate test:
* url 'https://httpbin.org/anything'
* form field foo = 'one/two?three=four'
* method post
You can see that the "raw" request is:
1 > POST https://httpbin.org/anything
1 > Content-Type: application/x-www-form-urlencoded
1 > Content-Length: 28
1 > Host: httpbin.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.11)
1 > Accept-Encoding: gzip,deflate
foo=one%2Ftwo%3Fthree%3Dfour
But in the response, you can see the server handled it correctly:
1 < 200
1 < Date: Wed, 06 Oct 2021 12:06:10 GMT
1 < Content-Type: application/json
1 < Content-Length: 513
1 < Connection: keep-alive
1 < Server: gunicorn/19.9.0
1 < Access-Control-Allow-Origin: *
1 < Access-Control-Allow-Credentials: true
{
"args": {},
"data": "",
"files": {},
"form": {
"foo": "one/two?three=four"
},
"headers": {
"Accept-Encoding": "gzip,deflate",
"Content-Length": "28",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "Apache-HttpClient/4.5.13 (Java/11.0.11)",
"X-Amzn-Trace-Id": "Root=1-615d9132-260dcbf96f57a6992b6273dc"
},
"json": null,
"method": "POST",
"origin": "122.179.54.225",
"url": "https://httpbin.org/anything"
}
See the JSON field called form in the response.
I think you should do some research, or talk to your "server" team. Who knows, maybe Karate has found a bug for you.

Google Analytics API call frequently returns expected data but occasionally the same call returns error 500

we have been running Google Analytics(GA) API for several accounts .
It works well for all the accounts except for one which occasionally(not always) fails and returns the error 500.
Regarding the account with the problem, the error 500 started to happen since last year(2020/DEC).
The occurrence of this error(500) shows a tendency to happen when the API CALL is made to fetch reports for periods over 3 days (However the chance of this error for periods shorter than 3 days so far has not been zero.)
Regarding the explanation above↑ the problem seems to be in GA side.
May we ask your assistance to check up the situation and help us to solve the problem.
We deeply appreciate all your help and kindness.
Below, As an example I paste the returned response(error 500) for the API call we made in 2021/JULY/8.
Best regards,
Shahin
I, [2021-07-09T18:11:44.314945 #13000] INFO -- : get https://analytics.googleapis.com/analytics/v3/data/ga?dimensions=ga%3Adate%2Cga%3AadDistributionNetwork%2Cga%3AsourceMedium%2Cga%3AadKeywordMatchType%2Cga%3Akeyword%2Cga%3AadContent%2Cga%3Acampaign&end-date=2021-07-08&ids=ga%3A61390358&max-results=1000&metrics=ga%3Agoal11Completions%2Cga%3Agoal12Completions%2Cga%3Agoal13Completions%2Cga%3Agoal14Completions%2Cga%3Agoal15Completions%2Cga%3Agoal16Completions%2Cga%3Agoal17Completions%2Cga%3Agoal18Completions%2Cga%3Agoal19Completions%2Cga%3Agoal20Completions&samplingLevel=HIGHER_PRECISION&start-date=2021-07-04&start-index=2001
D, [2021-07-09T18:11:48.813256 #13000] DEBUG -- request: User-Agent: "analytics/v3 google-api-ruby-client/0.8.6 Linux/2.6.32-431.el6.x86_64\n (gzip)"
Accept-Encoding: "gzip"
Content-Type: ""
Authorization: "Bearer ya29.a0ARrdaM9m7nl7eZ40UtyNPMLo-quMyknO5gC6d60ucF2zhN3WgO_YcsHtldGyqpjuTsHUJAFurvcC3cryutiB2U2P_Wf-gM6DtnhkAqEjoPfCKwsWeuz8wrFgXfa7M3QknRcFDFrWO0CNrEKeDG7caf0B1R49Rws"
Cache-Control: "no-store"
D, [2021-07-09T18:11:48.813315 #13000] DEBUG -- request:
I, [2021-07-09T18:12:48.790970 #13000] INFO -- Status: 500
D, [2021-07-09T18:12:48.791044 #13000] DEBUG -- response: vary: "Origin, X-Origin, Referer"
content-type: "application/json; charset=UTF-8"
date: "Fri, 09 Jul 2021 09:12:48 GMT"
server: "ESF"
cache-control: "private"
x-xss-protection: "0"
x-frame-options: "SAMEORIGIN"
x-content-type-options: "nosniff"
alt-svc: "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
connection: "close"
transfer-encoding: "chunked"
D, [2021-07-09T18:12:48.791065 #13000] DEBUG -- response: {
"error": {
"code": 500,
"message": "There was an internal error.",
"errors": [
{
"message": "There was an internal error.",
"domain": "global",
"reason": "internalError"
}
]
}
}

Google Calendar API returns a rate limit exceeded error during batch processing

Following my previous question ... I changed the Google Calendar API call to batch, but some requests in the batch return a 403 - rateLimitExceeded "Rate Limit Exceeded" error. There is always a maximum of 50 requests of the same type in the batch, most often PATCH. But errors occur even if the batch contains less than 10 requests. On average, only about 50% of all requests are successful.
Example request (part with one reguest):
--googlebatch_20200513_171515_647
Content-Type: application/http
Content-ID: <item:0>
PATCH /calendar/v3/calendars/XXX/YYY
Content-Type: application/json
Content-Length: 449
{
"summary": "Opakovaná aktivita 2",
"description": "",
"id": "XXX",
"start": { "dateTime": "2020-05-07T09:00:00+02:00" },
"end": { "dateTime": "2020-05-07T09:30:00+02:00" },
"location": "",
"visibility": "default",
"reminders": {"useDefault": false},
"transparency": "opaque",
"extendedProperties": {
"private": {
"X-QIID": "29037717,10",
"X-QISyncOn": "1"
}
}
}
...
next requests
...
--googlebatch_20200513_171515_647--
Example response:
--batch_preSx1sqdvk_AAP51GVWcoo
Content-Type: application/http
Content-ID: <response-item:0>
HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=UTF-8
Date: Mon, 13 May 2020 15:15:16 GMT
Expires: Mon, 13 May 2020 15:15:16 GMT
Cache-Control: private, max-age=0
Content-Length: 199
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "rateLimitExceeded",
"message": "Rate Limit Exceeded"
}
],
"code": 403,
"message": "Rate Limit Exceeded"
}
}
--batch_preSx1sqdvk_AAP51GVWcoo--
I don't understand why the Google API returns this error, because when I send a batch request, I just send the batch and the execution of individual requests is controlled by Google itself. So I have no way to influence the speed of their launch. If batch execution is too fast, why doesn't Google slow it down and complete all requests successfully?
What else could I do? Where could be the mistake? What do you recommend me?
Thank you. Regards, Petr.
There are known issues with the Calendar API throwing 403 error sooner than expected when using a service account
The workaround would be using impersonation, that is to make the service-account act on behalf of a user. This allows to avoid the 403 errors.
See here for code samples.

How to specify the correct USER_ID in analyticsreporting.userActivity.search?

I am trying to retrieve data linked to USER_ID by analyticsreporting.userActivity.search of Analytics Reporting API v4 using Google APIs Explorer.
But, when I make a Request body according to the official sample, the result that USER_ID does not exist is returned.
The Request sent and the Response returned are below.
(ViewID was omitted.)
POST https://analyticsreporting.googleapis.com/v4/userActivity:search?key={YOUR_API_KEY}
{
"viewId": "(Omitted)",
"user": {
"type": "USER_ID",
"userId": "28"
},
"dateRange": {
"startDate": "2019-05-20",
"endDate": "2019-05-26"
}
}
400
- Hide headers -
cache-control: private
content-encoding: gzip
content-length: 114
content-type: application/json; charset=UTF-8
date: Mon, 27 May 2019 11:14:44 GMT
server: ESF
vary: Origin, X-Origin, Referer
{
"error": {
"code": 400,
"message": "USER_ID: 28 not found.",
"status": "INVALID_ARGUMENT"
}
}
The specified USER_ID uses a User-ID value that can be verified in the Google Analytics User Explorer.
I tried to specify numbers such as 1 or 2 and other IDs displayed in User Explorer for the value of USER_ID, but the result was the same.
And I deleted the dateRange but the result was the same.
As with changing the ViewID, the error message is changed to "No permission to view", so the ViewID is not a problem.
Please tell me the correct specification method of USER_ID.
thank you.

Resources