How to create api in wso2am by payload - wso2-api-manager

I deployed wso2am-4.0 on my vm, I tried to create api by curl. I'm so confused I don't know how to add params in paylod. I guess that params could be added to payload in operations section. but there are no attribute about params. How to add body or query params in payload?
{
"name": "PizzaShackAPI",
"description": "This is a simple API for Pizza Shack online pizza delivery store.",
"context": "pizza",
"version": "1.0.0",
"provider": "admin",
"lifeCycleStatus": "CREATED",
"responseCachingEnabled": false,
"hasThumbnail": false,
"isDefaultVersion": false,
"enableSchemaValidation": false,
"type": "HTTP",
"transport": [
"http",
"https"
],
"tags": [
"substract",
"add"
],
"policies": [
"Unlimited"
],
"apiThrottlingPolicy": "Unlimited",
"securityScheme": ["oauth2"],
"maxTps": {
"production": 1000,
"sandbox": 1000
},
"visibility": "PUBLIC",
"visibleRoles": [],
"visibleTenants": [],
"subscriptionAvailability": "CURRENT_TENANT",
"additionalProperties": [
{
"name" : "AdditionalProperty",
"value" : "PropertyValue",
"display" : true
}
],
"accessControl": "NONE",
"businessInformation": {
"businessOwner": "John Doe",
"businessOwnerEmail": "johndoe#wso2.com",
"technicalOwner": "Jane Roe",
"technicalOwnerEmail": "janeroe#wso2.com"
},
"endpointConfig": {
"endpoint_type": "http",
"sandbox_endpoints": {
"url": "https://localhost:9443/am/sample/pizzashack/v1/api/"
},
"production_endpoints": {
"url": "https://localhost:9443/am/sample/pizzashack/v1/api/"
}
},
"operations": [
{
"target": "/order/{orderId}",
"verb": "POST",
"throttlingPolicy": "Unlimited"
"uriMapping": "uriMapping-test1",
"payloadSchema": "payloadSchema-test1"
},
{
"target": "/menu",
"verb": "GET",
"throttlingPolicy": "Unlimited",
"uriMapping": "uriMapping-test2",
"payloadSchema": "payloadSchema-test1"
}
]
}
In ui, there would be added like below:

For this you need to do a Swagger PUT - https://apim.docs.wso2.com/en/4.0.0/reference/product-apis/publisher-apis/publisher-v2/publisher-v2/#tag/APIs/operation/getAPISwagger
The API payload does not support adding these Swagger specific stuff.
Here is a sample definition for the resource check - https://gist.github.com/pubudu538/8a8eec6663cc0bbf97302bf50a7f2194#file-swagger-put-L354

Related

Why are my posts content not showing on my admin dashboard?

I have added an application to my WordPress site with a plug in that am using to automatically add posts with a python scripts. My API is working just fine even after testing on postman.
However the post Meta Desc and Key Phrase columns don't show anything as in a post added manually. (See screenshot; the first post is the one added via an api). I will appreciate any idea as to why this is.
post = {
'title': question_title,
'status': 'publish',
"content": question,
"type": "post",
"categories": [2],
"focus_keyphrase": question_title,
}
gradeboosts_url = "https://gradeboosts.com/wp-json/wp/v2"
user = 'aloy'
password = '****************'
creds = user + ':' + password
token = base64.b64encode(creds.encode())
headers = {'Authorization': 'Basic ' + token.decode('utf-8')}
r = requests.post(gradeboosts_url + '/posts', json=post, headers=headers)
A full postman get request that is displaying all columns on wordpress:
response = {
"id": 1692997,
"date": "2021-08-13T12:43:38",
"date_gmt": "2021-08-13T12:43:38",
"guid": {
"rendered": "https://gradeboosts.com/health-sciences-homework-help-3/"
},
"modified": "2021-08-13T12:43:38",
"modified_gmt": "2021-08-13T12:43:38",
"slug": "health-sciences-homework-help-3",
"status": "publish",
"type": "post",
"link": "https://gradeboosts.com/health-sciences-homework-help-3/",
"title": {
"rendered": "Health Sciences homework help"
},
"content": {
"rendered": "<p>Health Sciences homework help. An ion is an atom that has gained or lost one or more electrons.</p>\n<p> I don’t think that this is maths, but more chemistry.<br />\nAn ion is an atom that has a charge due to a lost or gain of electrons. Usually, ions occur when the atom tries to get a full outershell, either by losing electrons (and thus gaining a positive charge) or by gaining electrons (and thus getting a negative charge).</p>\n<p>Health Sciences homework help</p>\n",
"protected": false
},
"excerpt": {
"rendered": "<p>What’s an ion?</p>\n",
"protected": false
},
"author": 2,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": {
"spay_email": ""
},
"categories": [],
"tags": [],
"yst_prominent_words": [],
"jetpack_featured_media_url": "",
"_links": {
"self": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/posts/1692997"
}
],
"collection": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/posts"
}
],
"about": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/users/2"
}
],
"replies": [
{
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/comments?post=1692997"
}
],
"version-history": [
{
"count": 190,
"href": "https://gradeboosts.com/wp-json/wp/v2/posts/1692997/revisions"
}
],
"predecessor-version": [
{
"id": 1698135,
"href": "https://gradeboosts.com/wp-json/wp/v2/posts/1692997/revisions/1698135"
}
],
"wp:attachment": [
{
"href": "https://gradeboosts.com/wp-json/wp/v2/media?parent=1692997"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/categories?post=1692997"
},
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/tags?post=1692997"
},
{
"taxonomy": "yst_prominent_words",
"embeddable": true,
"href": "https://gradeboosts.com/wp-json/wp/v2/yst_prominent_words?post=1692997"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}

Logic App > Cosmos PartitionKey Not Matching Error

I'm scared to put this out there because it should be so easy and I am facing the same issue as the post here, here and here and I have tried each of the answers to no avail. Below is the current Resulting Input (redacted) and Related CodeView of the inputs.
The Result
{
"method": "post",
"headers": {
"x-ms-documentdb-raw-partitionkey": "\"2020\""
},
"path": "/dbs/xxxx/colls/smtp/docs",
"host": {
"connection": {
"name": "/subscriptions/..."
}
},
"body": {
"category": [
[
"cat facts"
]
],
"email": "example#test.com",
"event": "processed",
"id": "yada",
"partitionKey": "\"2020\"",
"sg_event_id": "yada yada",
"sg_message_id": "yada",
"smtp-id": "yada",
"timestamp": 1604345542
}
}
The Code View
{
"inputs": {
"body": {
"category": [
"#items('For_each')['category']"
],
"email": "#items('For_each')['email']",
"event": "#items('For_each')['event']",
"id": "#items('For_each')['sg_message_id']",
"partitionKey": "\"#{formatDateTime(utcNow(),'yyyy')}\"",
"sg_event_id": "#items('For_each')['sg_event_id']",
"sg_message_id": "#items('For_each')['sg_message_id']",
"smtp-id": "#items('For_each')['smtp-id']",
"timestamp": "#items('For_each')['timestamp']"
},
"headers": {
"x-ms-documentdb-raw-partitionkey": "\"#{formatDateTime(utcNow(),'yyyy')}\""
}
}
The error I'm getting is the usual one - PartitionKey extracted from document doesn't match the one specified in the header
I just can't see what I'm missing here now.
Thanks all.
First, as Matias comments, check your partition key path.
Then, change this code "partitionKey": "\"#{formatDateTime(utcNow(),'yyyy')}\"", to "partitionKey": "#{formatDateTime(utcNow(),'yyyy')}", in your document.
It works fine on my side:

The language expression property '0' can't be evaluated, property name must be a string - ARM Template error while adding Key Vault access policy

I've been working on an issue and seem to be stuck, so asking on so in case anyone can help.
To describe the issue, I've got an existing Azure Key Vault setup, and wish to add a number of access policies to this resource group. It needs to be conditional as if the function name is "false" then that function should not be added to key vault access policy.
variable section:
"variables": {
"functionAccess": {
"value": [
{
"name": "[parameters('Function_1')]"
},
{
"name": "[parameters('Function_2')]"
},
{
"name": "[parameters('Function_3')]"
}
]
}
}
My Template :
{
"apiVersion": "2016-10-01",
"condition": "[not(equals(variables('functionAccess')[CopyIndex()].name, 'false'))]",
"copy": {
"batchSize": 1,
"count": "[length(variables('functionAccess'))]",
"mode": "Serial",
"name": "accessPolicies"
},
"name": "[concat(parameters('KeyVault_Name'), '/add')]",
"properties": {
"accessPolicies": [
{
"tenantId": "[subscription().tenantId]",
"objectId": "[if(not(equals(variables('functionAccess')[CopyIndex()].name, 'false')), reference(concat('Microsoft.Web/sites/', variables('functionAccess')[CopyIndex()].name), '2016-08-01', 'Full').identity.principalId, json('null'))]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
]
},
"type": "Microsoft.KeyVault/vaults/accessPolicies"
}
When I deploy my ARM template for the azure key vault I got this error message:
The language expression property '0' can't be evaluated, property name must be a string.
also tried below, but same error:
{
"apiVersion": "2018-02-14",
"name": "[concat(parameters('KeyVault_Name'), '/add')]",
"properties": {
"copy": [
{
"batchSize": 1,
"count": "[length(variables('functionAccess'))]",
"mode": "serial",
"name": "accessPolicies",
"input": {
"condition": "[not(equals(variables('functionAccess')[copyIndex('accessPolicies')].name, 'false'))]",
"tenantId": "[subscription().tenantId]",
"objectId": "[if(not(equals(variables('functionAccess')[copyIndex('accessPolicies')].name, 'false')), reference(concat('Microsoft.Web/sites/', variables('functionAccess')[copyIndex('accessPolicies')].name), '2016-08-01', 'Full').identity.principalId, json('null'))]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
}
]
},
"type": "Microsoft.KeyVault/vaults/accessPolicies"
}
There are a few options for dealing with filtering an array for copy operation. I deploy my ARM templates from PowerShell scripts and use PowerShell to setup parameter values. When I need special logic handle different inputs for different environments, I let PowerShell handle it.
If you must handle the filtering in ARM and you have the option to input a CSV list of functions, then perhaps the following will work. You can then use the functionAccessArray to iterate over in the copy operation.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
"functionAccessCsv": "Function-0,Function-1,false,Function-4,false,Function-6,Function-7",
"functionAccessFiltered": "[replace(replace(variables('functionAccessCsv'), 'false', ''), ',,', ',')]",
"functionAccessArray": "[split(variables('functionAccessFiltered'), ',')]"
},
"resources": [
],
"outputs": {
"functionAccessCsvFiltered": {
"type": "string",
"value": "[variables('functionAccessFiltered')]"
},
"functionAccessArray": {
"type": "array",
"value": "[variables('functionAccessArray')]"
}
}
}
The result:
I just had the same issue. By using an array parameter with a default value instead of a variable, I got it to work.
"parameters": {
"functionAccess": {
"type": "array",
"defaultValue": [
"value1",
"value2",
"value3"
]
}
}

"The metric names were not found" when deploying microsoft.insights/metricAlerts

I'm trying to deploy a MetricAlert with my Traffic Manager Profile and I always get {
"Code": "BadRequest",
"Message": "The metric names were not found ."
}
I'm trying to use the Endpoint Status by Endpoint metric and having no luck. Any idea what the correct metric name would be or how I can find it?
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "microsoft.insights/metricAlerts",
"apiVersion": "2018-03-01",
"name": "All-PPE-Endpoints-Down",
"location": "global",
"tags": {
"displayName": "Alert-AllEndpointsDown"
},
"properties": {
"actions": [
{
"actionGroupId": "[resourceId('microsoft.insights/actionGroups', 'TDFFCEmailActionGroup')]"
}
],
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
"allOf": [
{
"criterionType": "DynamicThresholdCriterion",
"name": "1st criterion",
"metricName": "Endpoint Status by Endpoint(Platform)",
"dimensions": [],
"operator": "LessThan",
"alertSensitivity": "Medium",
"failingPeriods": {
"numberOfEvaluationPeriods": "4",
"minFailingPeriodsToAlert": "3"
},
"timeAggregation": "Maximum"
}
]
},
"description": "All endpoints are not responding to ping",
"enabled": true,
"evaluationFrequency": "PT5M",
"scopes": [
"/subscriptions/84eba200-00a9-41d3-9916-d63b2e25da02/resourceGroups/tdff5-rg-ppe/providers/Microsoft.Network/trafficManagerProfiles/tdfppegas"
],
"severity": 3,
"windowSize": "PT5M"
}
}
]
}
The metrics documentation webpage which describes all of the built-in metrics can be found here: https://learn.microsoft.com/en-us/azure/azure-monitor/platform/metrics-supported#microsoftnetworktrafficmanagerprofiles
In this case, the key I was looking for was ProbeAgentCurrentEndpointStateByProfileResourceId

Provide request header for Microsoft.Scheduler/jobCollections/jobs

I want to know how to provide from my Azure WebApp the user/password to provide header for my webjob
{
"name": "[concat('TraitementTableAzure-', parameters('HeliosEnvironnementName'), '-js')]",
"type": "jobs",
"apiVersion": "2016-03-01",
"location": "[resourceGroup().location]",
"properties": {
"action": {
"request": {
"method": "Post",
"uri": "[concat('https://', parameters('AzureWebAppWebJobs'), '.scm.azurewebsites.net/api/triggeredwebjobs/', parameters('HeliosEnvironnementName'), '_TraitementTableAzure/run')]",
"headers": {
"authorization": "[concat('Basic ', reference('???').???)]" }
},
"type": "Http",
"retryPolicy": {
"retryType": "Fixed"
}
},
"startTime": "[parameters('SchedulesStartTime').SchedulerTraitementTableAzureStartTime]",
"recurrence": {
"frequency": "Day",
"interval": 1
},
"state": "Enabled"
},
"dependsOn": [
"[resourceId('Microsoft.Scheduler/jobCollections', variables('AzureSchedulerName'))]"
],
"tags": {
"displayName": "Cedule_TraitementTableAzure"
}
},
I found information over Azure Portal but not in ARM Template under webjob Properties. How can reference information on the blue arrow over my ARM template ?
How can reference information on the blue arrow over my ARM template ?
If we want to get the publishingPassword, then we could use ListPublishingCredentials API in the ARM template via list function, list(concat('Microsoft.Web/sites/', parameters('websisteName') ,'/config/publishingcredentials'), '2016-08-01').properties.publishingPassword
According to your template, it seems the that you want to call WebJob REST API, If it is that case, the authorization header is base64(publishusername:publishpassword).
base64(concat(list(concat('Microsoft.Web/sites/', parameters('websisteName'),'/config/publishingcredentials'), '2016-08-01').properties.publishingUserName,':',list(concat('Microsoft.Web/sites/', parameters('websisteName') ,'/config/publishingcredentials'), '2016-08-01').properties.publishingPassword))
I write a demo to test it on my side, it works correctly .
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"websisteName": {
"type": "string"
}
},
"resources": [],
"outputs": {
"base64Output": {
"type": "string",
"value": "[base64(concat(list(concat('Microsoft.Web/sites/', parameters('websisteName'),'/config/publishingcredentials'), '2016-08-01').properties.publishingUserName,':',list(concat('Microsoft.Web/sites/', parameters('websisteName') ,'/config/publishingcredentials'), '2016-08-01').properties.publishingPassword))]"
}
}
}

Resources