Translator Text API endpoint returning 404 code with message "Resource not found" as a JSON Object - azure

After creating a service for Text Translator of Azure service, the end point when tried with the one of the keys provided returns a json object with 404 error code and Message "Resource not found"
{
"error": {
"code": "404",
"message": "Resource not found"
}
}
Postman Parameters used are:
URL:
https://agro.cognitiveservices.azure.com/translate?api-version=3.0&to=ta,en
Body JSON:
{
[
"Text" : "Hello World"
]
}
With Ocp-Apim-Subscription-Key parameter in header, is that which was given as the subscription key for cognitive service of Azure when registering.
NOTE: HTTP POST Method used.
Please suggest a solution to resolve the problem and THANK YOU for this.
Screenshot Shared below as link:
enter image description here

Looking at Microsoft docs, your endpoint seems to be invalid. See https://learn.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-translate?pivots=programming-language-javascript
HTTP POST Endpoint: https://api.cognitive.microsofttranslator.com/?api-version=3.0&to=ta,en
headers: {
'Ocp-Apim-Subscription-Key': subscriptionKey,
'Content-type': 'application/json',
'X-ClientTraceId': uuidv4().toString()
}
Body:
body: [{
'text': 'Hello World!'
}]

Related

Creating a basic REST API in PolicyCenter

I am trying to create a basic HelloWorld REST API in PolicyCenter. I am getting an Internal Server Error from the GET /apis's endpoint (from the com.guidewire.pl.rest.docs.ApiListGenerator) and my new endpoint returns 404 Not Found. I am not sure what is missing and I don't see any clues in the logs. Any hints are welcome.
GET http://localhost:8180/pc/rest/apis
{
"status": 500,
"errorCode": "java.lang.IllegalArgumentException",
"cause": {
"class": "java.lang.IllegalArgumentException",
"message": "Keys in JsonObject cannot be null"
},
"stackTrace": [
"gw.api.json.JsonObject.validateKey(JsonObject.java:898)",
"gw.api.json.JsonObject.put(JsonObject.java:849)",
"com.guidewire.pl.rest.docs.ApiListGenerator.lambda$createApiListJson$2(ApiListGenerator.java:37)",
"java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)",
...
GET http://localhost:8180/pc/rest/helloworld
{
"status": 404,
"errorCode": "gw.api.rest.exceptions.NotFoundException",
"userMessage": "No resource was found at path /helloworld"
}
[modules\configuration\gsrc\myorg\pc\integration\restapi\helloworld\HelloWorldHandler.gs]
package myorg.pc.integration.restapi.helloworld
class HelloWorldHandler {
public function getHelloWorld() : String {
return 'Hello, World!'
}
}
[modules\configuration\config\integration\apis\myorg\pc\helloworld\helloworld-1.0.swagger.yaml]
swagger: "2.0"
info:
version: "1.0"
title: "Hello World API"
x-gw-apihandlers:
- myorg.pc.integration.restapi.helloworld.HelloWorldHandler
paths:
/helloworld:
get:
summary: "Says 'Hello World'"
description: "Says 'Hello World'"
operationId: getHelloWorld
produces:
- text/plain
responses:
'200':
description: |
Successful operation
schema:
type: string
[modules\configuration\config\integration\apis\published-apis.yaml]
apis:
- name: myorg.pc.helloworld.helloworld-1.0
defaultTemplate:
- name: gw.pl.framework.dev_template-1.0
After some digging I was able to find the documentation on the Swagger format, which mentioned basePath as a required property. After adding this, my API started working (with a different URL).

How can I pass Body Parameters to API Post operation using API Management Action in Logic App?

I have an azure function which works well when I call it from postman . I am trying to invoke the same from logic app as when an HTTP request is received. However, I am unable to pass raw content in the APIM as it does not give me an option for the same. It let me add only the subscription key.
My Azure APIM accepts file name, subscription key only.
Any help in this regard is much appreciated.
Postman : (I have added Headers - Content-Type, Accept: using )
Headers:
Content-Type :
Accept:
Ocp-Apim-Subscription-Key
Body:
{
"name": "olaf"
}
Azure Logic App: (Using Peek Code);
{
"inputs": {
"method": "post",
"headers": {
"Accept": "application/json",
"Content-Type": "text/csv"
},
"pathTemplate": {
"template": "/scg-liquidTransformer-functionApp/liquidtransformer/{liquidtransformfilename}",
"parameters": {
"liquidtransformfilename": "#{encodeURIComponent('xmlsample.liquid')}"
}
},
"api": {
"id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXX/resourceGroups/scg-mel-dev-arg-liquidtransformer/providers/Microsoft.ApiManagement/service/scg-liquidTransformer-functionApp-apimservice/apis/scg-liquidtransformer-functionapp"
},
"subscriptionKey": "XXXXXXXXXXXXXXXXXXXXXXXX"
}
}
I need to send body {} as a parameter input in the azure functionenter image description here.
Thanks,
Paul.
enter image description here
You need to do configuration in your APIM, please refer to the steps below:
1. Go to your APIM, find your api and click the "pencil" icon.
2. In next page, click "Request" tab and click "Add representation" to add "application/json".
3. Then click "New definition"
4. Input the json sample of request body, it will generate the schema automatically in "Payload" box.
5. Click "Save", then go back to your logic app and add the APIM api. You can find there is a field "name" for you to choose.

Getting Http 500 error when calling QnA api with strictfilter

I am getting Http 500 error whenever i am calling the QnAMaker Api with Metadata(strictFilter) body. Am I not following any instruction before calling Apis?
QnA maker api is working perfectly if I am not adding strictFilter in the Api request body.
api request details:
URL: https://qnamaker endpoint/qnamaker/knowledgebases/KBID/generateAnswer
Method: POST
content-type: application/json
Authorization: EndpointKey Key
Body:
{
"question": "hi",
"top": 3,
"strictFilters": [
{
"name": "category",
"value": "pears"
}
]
}
I have even read the Microsoft documentation
Still no luck for me here.
QnaMaker Response Error with StrictFilter screenshot

creating subscription with Microsoft Graph API error

I'm trying to create a subscription to receive notification about changes to Office365 Calendar. I have already worked with Outlook Notitication API but having a problem with Microsoft Grap API
I try to create a subscription using Http Post to https://graph.microsoft.com/beta/subscriptions with header and body:
Header: Content-Type: application/json; Authorization : Bearer {accessToke}
Body:
{
"resource": "me/calendars",
"notificationUrl": "sample notification url",
"changeType": "Created",
}
In my notification url, i've setup to send a response with the value of validation token when receveving a validation request
Finally, the result i received:
{
"error": {
"code": "ExtensionError",
"message": "There was an error processing a storage extension.",
"innerError": {
"request-id": "6c563931-511d-415d-9c04-c07f25d45b1f",
"date": "2016-03-20T08:10:32"
}
}
}
I wonder what I'm doing wrong or that's a internal error of MS Grap API. Can anyone help me? Thank in advance
The correct resource to use for calendar events is "me/events". We'll try to get a better error message in future.

Insert event with Google Calendar API in Chrome Extension keeps failing

I'm having trouble getting the format right for a chrome extension using the Google Calendar API. I have an OAuth2 access token (which is valid, I can test that with tokenInfo), but am having trouble. I'm using a proprietary framework to build the extension, which complicates things, but maybe you could help me find out what information I'm missing:
var eventParams = e.data,
request = {
'method' : 'POST',
'async' : true,
'url': 'https://www.googleapis.com/calendar/v3/calendars/'+CAL_ID + '/events',
'headers': {
'Authorization' : TOKEN
},
'params': eventParams
};
My token looks like this:
{↵ "issued_to": "831101123055-874tukfvuvkma6s0l7m70iqlc3lirnkc.apps.googleusercontent.com",↵ "audience": "831101123055-874tukfvuvkma6s0l7m70iqlc3lirnkc.apps.googleusercontent.com",↵ "scope": "https://www.googleapis.com/auth/calendar",↵ "expires_in": 3600,↵ "access_type": "offline"↵}
The error I'm getting is:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
I'm not really sure why that's the case, because my request is authenticated. Am I not passing the token correctly? Someone has suggested that I need to include an API key, but my understanding is that API keys are only for apps requiring public access and don't need access to user data, and that OAuth2 takes the place of an API key.
I'd appreciate any help you guys can offer! Thank you!
Turns out the error was kind of anomalous, the problem turned out to be with the data type. The correct syntax was:
var eventParams = e.data,
request = {
'method' : 'POST',
'async' : true,
'url': 'https://www.googleapis.com/calendar/v3/calendars/' + CAL_ID + '/events',
'headers': {
'Authorization' : TOKEN_TYPE+' '+ TOKEN,
'Content-Type': 'application/json'
},
'contentType': 'json',
'params': JSON.stringify(eventParams)
};
Please make sure that you have calendar API enabled in the developers console:
https://console.developers.google.com

Resources