Azure API Management policy: validate request body against json schema - azure-api-management

I am trying to implement a content validation policy in Azure API management.
I created a schema named event.
The policy looks like this:
<validate-content unspecified-content-type-action="prevent" max-size="12000" size-exceeded-action="prevent" errors-variable-name="validationErrors">
<content type="application/json" validate-as="json" action="prevent" schema-id="event" schema-ref="#/components/schemas/event" />
</validate-content>
When I try to test it, I get an error message in trace saying that the schema reference is wrong:
"details": "Could not resolve schema reference '#/components/schemas/event'. Path '', line 1, position 1."
Documentation says:
<content type="content type string" validate-as="json|xml|soap" schema-id="schema id" schema-ref="#/local/reference/path" action="ignore|prevent|detect" />
But I didn't find any clue how to find the schema-id and the schema-ref attributes.
When I open the schema there's nothing like this on the screen neither in the "Overview" nor under "Properties". Please someone tell me how to fill these to make the policy working. Or, if it exists, point me to the documentation where I can read it :)

schema-id and schema-ref both are optional attributes for validating request body against json schema.
As per this Azure API Management validation policies | Microsoft Docs:
schema-id: Name of an existing schema that was added to the API Management instance for content validation. If not specified, the default schema from the API definition is used.
schema-ref: For a JSON schema specified in schema-id, optional reference to a valid local reference path in the JSON document. Example: #/components/schemas/address. The attribute should return a JSON object that API Management handles as a valid JSON schema.
Make sure to check Azure API Management validation policies | Microsoft Docs schemas for content validation, provide correct schema location whether you are importing from a file or URL.

Related

How to specify JSON parameters in a WADL file?

Dear StackOverflow Experts,
We have a requirement to access an API from SAP BODS. SAP BODS needs a WADL file configured in order to access the API. The API we are trying to call is a rest services API with a POST method and accepts only JSON parameters as input.
I have tried using SOAP UI to generate the WADL file but the WADL file does not include the JSON input parameters in the file.
Can anyone help me with a sample code of how a JSON input can be specified as a parameter in the WADL file.
I have tried going through all the documentation that is available but could not come across anything that could help.
I am new to API and any help is appreciated.

Is there a way to access entity value metadata in Watson Assistant using the JSON editor or SPEL

I'm attempting to define some relationships between entity values, using metadata.
I've uploaded metadata to an entity value using the Watson API v1. When I list the entities through the same API I can see the metadata. I have not been able to access the metadata from Watson Assistant though.
As a test I changed the entity value and checked through Watson Assistant it was changed, so I know I'm working with the correct workspace. I've also checked the entity using the JSON editor to verify it was defined and tried assigning the entity to a context variable.
I've tried several methods including:
#Room.building, #Room.metadata.building, entities['Room']?metadata?.building, entities['Room']?.building (all within the < ? tags). Using #Room and entities['Room']?.value returns the entity value correctly. It's accessing the metadata where it fails.
The metadata for building should not be returning null, but I"m either receiving a null or, depending on how I'm attempting to retrieve the value, a SPEL exception - no property on undefined.
Unfortunately, it is not possible to access metadata defined on user entities in the WA runtime at this moment. The metadata are only returned when making the direct API call. You could use cloud functions call though to get the metadata in WA although that is not ideal either.

Content Property error on confluence cloud error

i am developing an addon on confluence cloud and i needed to store a value .i am persuing this tuto in the link bellow https://developer.atlassian.com/static/connect/docs/latest/modules/confluence/content-property.html
after declaring this value "ideation " in section "confluenceContentProperties" in my descriptor json file, i get this error in my console
The add-on descriptor failed to validate against the schema. Please confirm this add-on is intended for use with Confluence and then contact the add-on vendor.
/confluenceContentProperties/0: object has missing required properties (["key"])
You also need to update atlassian-connect.json file and ensure that the values are correct. You can also validate your json file with this validator.

Call rest service that returns JSON in mule esb?

How to call a rest service that returns JSON in a APIKit based message flow. I want to prepare the request for Rest service and want to extract the JSON message in a message flow.
Can any one help me to do this?
Thanks
The recommended way to invoke/consume REST services in mule is the use of HTTP Request
Do let us know if there is a specific you are facing
The request connector is especially handy when consuming a RESTful API
that is described in a RAML file. If you reference the API's RAML file
in the connector's configuration, it will proactively offer you the
set of available resources and operations contained in the RAML file,
as well as enforce the policies described in the file. It will also
expose the API metadata to Studio, which can then be used by other
elements such as DataWeave to autocomplete fields and make
configuration much easier
Use Rest URI path to invoke the Service and you can also get json response as output based on the type of service you invoke

WSO2 API Manager Auth error content type

I have WSO2 API Manager configured and everything seems to work fine.
The only issues bothering me is that in case of an Auth exception, the API manager always returns the response with XML content type, e.g.,
<ams:fault xmlns:ams="http://wso2.org/apimanager/security"><ams:code>900904</ams:code><ams:message>Access Token Inactive</ams:message><ams:description>Access failure for API: /exchange, version: 1.0 with key: 1139a466ebfd825aca953ad7259b9f45</ams:description></ams:fault>
In case of client communicates with my web service with JSON format, the XML response will look a little bit strange.
Is there any ideas how to make API Manager provide error response in JSON format?
This has been addressed in recent versions of API Manager. Auth errors can be set to json format by adding or updating the error_message_type property in WSO2HOME/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml:
<property name="error_message_type" value="application/json"/>
I've found this also requires JSONBuilder and JSONMessageFormatter to be selected for the json content type in axis2.xml (which is the default setting).
For older versions, this article explains how to manually do the same.