Azure API Management - Optional Parameters - azure

I'm trying to work with optional Query parameters. But when I try to access this parameter in my body mapping to my backend SOAP service, I get no results.
I defined the parameter like this.
And I'm trying to access it in my Liquid template with this code.
{{context.Request.Url.Query.GetValueOrDefault("test","false")}}
But the result is just empty. Could somebody help me to find what I'm doing wrong here?

Try using context.Request.OriginalUrl instead. OriginalUrl is what comes into the Gateway. context.Request.Url is after it has been rewritten for the backend.

Related

Azure Data Factory - Parameter interpolation

I'm trying to add a pipeline parameter into the body of a post request to an Azure Function app in Azure Data Factory. It appears that the string isn't getting replaced, but the Microsoft documentation suggests I'm doing it the right way. See here: https://learn.microsoft.com/en-gb/azure/data-factory/control-flow-web-activity#request-payload-schema
This is a screenshot of an error I'm getting alongside it:
I'm confused as to how to proper interpolate pipeline parameters into this request
Thanks!
As mentioned in this document, wrap your parameter inside braces #{pipeline().parameters.ParameterName}.
Below is the example with my sample API post body:
{
"tourist_name": "#{pipeline().parameters.name}",
"tourist_email": "#{pipeline().parameters.email}",
"tourist_location": "#{pipeline().parameters.location}"
}

struggling to get 'deploy to azure button' to work

I'm struggling to get a Deploy to Azure button to work and hoping someone can help,
my code in the readme.md looks like
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/<url encoded link to raw template>
when I try the button it takes me to the deploy screen, only I get an error:
"(x) Error parsing template. Please ensure template is valid JSON. Invalid symbol at character position 4. (3 other errors)"
the template validates and works as expected when deployed manually through Deploy a Custom Template,
the raw uri to the template in our tfsgit repo returns the raw template as expected
(the raw uri uses msoft's pattern of https://dev.azure.com/{{organization}}/{{project}}/_apis/sourceProviders/{{providerName}}/filecontents?repository={{repository}}&path={{path}}&commitOrBranch={{commitOrBranch}}&api-version=5.0-preview.1)
I'm guessing might be some kind of authentification issue, I've tried basic auth with username:password#https://... or maybe it only works with github.com, either way I'm completely stuck
nothing I try seems to work, and azure won't show me the json it's trying to parse,
I was wondering if someone else has had a similar issue and would be able to point me in the right direction here
thanks in advance

Independent NPM library that validates request based on swagger file

We are building APIs using Swagger, AWS API gateway and Lambda functions with NodeJS. The API gateway will do the request validation, however as per the design, the lambda functions need to re-validate the request object as an API Gateway Proxy Request Event. This makes sense as in theory we can reuse the lambda functions by invoking them via other event source (e.g. SNS).
Therefore we need an NodeJS tool which can validate the request (not only body but also params, etc) based on the swagger spec - exactly what the swagger-tools and a few other tools (e.g. swagger-request-validator) are doing, but not as a middleware.
I did some search but could not find one, also looked into swagger-tools source code, reckon its validation component was written in the way that cannot be easily used separately.
Any suggestion is welcome. Thanks in advance.
You can use swagger-model-validator.
var Validator = require('swagger-model-validator');
var swaggerFile = require("./swagger.json");
const validator = new Validator(swaggerFile);
console.log(validator.validate({
name: 'meg'
}, swaggerFile.definitions.Pet, swaggerFile.definitions, true).GetErrorMessages())
This outputs:
[ 'photoUrls is a required field' ]
validator.validate returns an object, so you can also check if the returned object contains anything under the errors attribute. It should be as simple as
if (validator.validate({
name: 'meg'
}, swaggerFile.definitions.Pet, swaggerFile.definitions, true).errors) {
// do something with error
}
I have used Swagger's sample JSON for this answer.

What is the Azure API version

I'm trying to access the result of a GET request provided by Azure, as shown in the example : https://msdn.microsoft.com/sv-se/library/azure/dn820159.aspx
My problem is that the api-version is a mandatory argument, but I have no idea about what to write inside. I'm a bit lost with the Azure Batch documentation, it doesn't seem to be complete.
I found something in an Azure webpage : https://azure.microsoft.com/en-us/documentation/articles/search-api-versions/ and the api-version was api-version=2015-02-28. However, if I try it in my browser, I have this answer : "key":"Reason","value":"The specified api version string is invalid".
Any idea of what I can put inside the api-version parameter ?
Have a look here
As the time of this writing
The version of the Batch API described here is '2016-07-01.3.1', and
using that version is recommended where possible.
Earlier versions include '2016-02-01.3.0', '2015-12-01.2.1',
'2015-11-01.2.1', '2015-06-01.2.0', '2015-03-01.1.1', and
'2014-10-01.1.0'.
So try specifying '2016-07-01.3.1'

How do i access the Phabricator Maniphest restful APIs?

I'm trying to programmatically create tasks/bugs on Maniphest: https://www.phacility.com/phabricator/maniphest/
but i can't quite seem to find a RESTful API that can do this.
am i totally missing out on something? or does there not currently exist one
Conduit (https://secure.phabricator.com/book/phabricator/article/conduit/) should work for you. There is a method called createtask (looks like https://secure.phabricator.com/conduit/method/maniphest.createtask/) that is exactly what you are looking for.
You can access phabricator's api, to create task ,query user info etc.
here is the demo for access https api by postman .
Note: for multi value field such as "ccPHIDs" , you should use format like the image.
but in conduit UI Test. you have to use json format, like this: ["PHID-PROJ-xxx3", "PHID-PROJ-xx12"]
phabricator's API is the wrost api set, I have used by now. so sick...

Resources