error 403 when i post create request to openstack with restapi , how to fix? - api

I'm trying to do a post request for creating a server in the openstack using REST API. I tried this code (followed in the Openstack documentation) but it response 403 error code
request for token
{ "auth":
{ "identity":
{ "methods": ["password"],
"project": "7646jkkjds876tdsuhi87fd4d2a953ca3f4",
"password":
{"user":
{"domain":{"name": "default"},
"name": "test",
"password": "zxcZXC123#"
}
}
}
}
}
and my Request for creating the Server
{
"server": {
"name": "test-vm1",
"imageRef": "c8d859c9-ce15-4673-a486-5524ba1e41ff",
"flavorRef": "0",
"max_count": 1,
"min_count": 1,
"networks": [
{
"uuid": "01f1888b-1d12-4e6c-9936-d8175e71f311"
}
],
"security_groups": [
{
"name": "default"
}
]
}
}
please help me

I found the answer. This error is shown when you don't send the project scope in the API token. I corrected my JSON like this and it's done.
{ "auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "test",
"domain": { "id": "default" },
"password": "zxcZXC123"
}
}
},
"scope": {
"project": {
"name": "test",
"domain": { "id": "default" }
}
}
}
}

Related

Unable to retrieve data from catalog using WhatsApp Cloud API

I'm unable to send multiproduct messages to users. Every time I send the request I receive the same error. The following attachment shows the catalog connected to the number.
The body of the request:
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "###########",
"type": "interactive",
"interactive": {
"type": "product_list",
"header": {
"type": "text",
"text": "text-header-content"
},
"body": {
"text": "text-body-content"
},
"footer": {
"text": "text-footer-content"
},
"action": {
"catalog_id": "673529427462715",
"sections": [
{
"title": "the-section-title",
"product_items": [
{
"product_retailer_id": "K456653445"
}
]
}
]
}
}
}
The error received:
{
"error": {
"message": "(#131009) Parameter value is not valid",
"type": "OAuthException",
"code": 131009,
"error_data": {
"messaging_product": "whatsapp",
"details": "None of the products provided could be sent. Please check your catalog."
},
"error_subcode": 2494010,
"fbtrace_id": "A4YbEq8SQ7rMIisuc4M2HiX"
}
}

Tyk - request body is forwarded without being transformed

I am new to api gateways and I wanted to try to use Tyk product
I installed the docker version and created an api using the documentation
I tried to do a transformation using templates but the request was forwarded without any transformation
here is the Api configuration
{
"name": "Hello-World",
"slug": "hello-world",
"api_id": "Hello-World",
"org_id": "1",
"use_keyless": true,
"auth": {
"auth_header_name": "Authorization"
},
"definition": {
"location": "header",
"key": "x-api-version"
},
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default",
"use_extended_paths": true
},
"extended_paths": {
"transform": [
{
"path": "/widgets",
"method": "POST",
"template_data": {
"template_mode": "file",
"template_source": "./templates/transform_test.tmpl"
}
}
]
}
}
},
"proxy": {
"listen_path": "/widgets",
"target_url": "http://7857-102-158-57-156.ngrok.io/api/v1",
"strip_listen_path": true
},
"active": true
}
The target_url is pointing to dummy express service that responds with the request body.
here is the template I am using
{
"value1": "{{.value2}}",
"value2": "{{.value1}}",
"transformed_list": [
{{range $index, $element := .value_list}}
{{if $index}}
, "{{$element}}"
{{else}}
"{{$element}}"
{{end}}
{{end}}
]
}
and this is the input I am trying to transform
{
"value1": "value-1",
"value2": "value-2",
"value_list": [
"one",
"two",
"three"
]
}
There seems to be an issue with your API definition file. The extended_paths section should be a child of the Default field. This is what it should look like
{
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default",
"use_extended_paths": true,
"extended_paths": {
"transform": [
{
"path": "/widgets",
"method": "POST",
"template_data": {
"template_mode": "file",
"template_source": "./templates/transform_test.tmpl"
}
}
]
}
}
}
}
}

Whatsapp API (#132000) Number of parameters does not match the expected number of params

I created below template in Whatsapp API. And I want to set the parameter value in the API call. What is the correct payload ? I have been following the Meta docs and trying but everytime I get error. Please Help.
Template:
You order # {{1}} is received successfully.
I used this payload:
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
But I am still getting this error
{
"error": {
"message": "(#132000) Number of parameters does not match the expected number of params",
"type": "OAuthException",
"code": 132000,
"error_data": {
"messaging_product": "whatsapp",
"details": "body: number of localizable_params (0) does not match the expected number of params (1)"
},
"error_subcode": 2494002,
"fbtrace_id": "AzPa-uWXctIcdNVu0Lf3Fic"
}
}
The issue due to closing the template object then opening a new component object.
make the component object inside the template object and it will be fixed
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
}
change in parameter type "header", this code run for me:
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "text",
"text": "xxxxxxx"
}
]
}
]
}
}
Looks like the template is expecting 1 parameter, which is not being provided.
You can look at the documentation and example here.
It includes a working example.

geoserver upload kml no format

I'm using the API of the geoserver (link) to upload a new kml file to mu local machine using a post request to http://localhost:8080/geoserver/rest/imports with the following json
{
"import": {
"targetWorkspace": {
"workspace": {
"name": "sample"
}
},
"targetStore": {
"dataStore": {
"name": "sample"
}
},
"data": {
"type": "file",
"file": "/data/sample_dir/sample.kml"
}
}
}
I should get the data type and the state as ready on the response according to the API documentation but I'm getting a pending and no file format.
Response:
{
"import": {
"id": 23,
"href": "http://localhost:8080/geoserver/rest/imports/23",
"state": "PENDING",
"archive": false,
"targetWorkspace": {
"workspace": {
"name": "sample"
}
},
"targetStore": {
"dataStore": {
"name": "sample",
"type": "Directory of spatial files (shapefiles)"
}
},
"data": {
"type": "file",
"format": null,
"file": "sample.kml"
},
"tasks": []
}
}
Apparently the geoserver don't accept the relative path like it says on the API documentation.
If instead of:
"data": {
"type": "file",
"file": "./data/sample_dir/sample.kml"
}
I use
"data": {
"type": "file",
"file": "/var/lib/tomcat7/webapps/geoserver/data/sample_dir/sample.kml"
}
on the request it works fine.

Jira REST API: create issue linked to another one

I'd like to link an issue to an existing one at creation using the REST API. The idea is not to CREATE then UPDATE, but just CREATE.
Here is my JSON:
{
"issueUpdates": [
{
"fields": {
"project": {
"key": "CMDB"
},
"issuetype": {
"id": "10500"
},
"summary": "VMP-MYSQL-01",
"issuelinks": [
{
"type": {
"name": "Relates",
"inward": "relates to",
"outward": "relates to"
},
"inwardIssue": {
"key": "CMDB-825"
},
"outwardIssue": "CMDB-825"
}
],
"customfield_10600": "VMP-MYSQL-01"
}
}
]
}
The error I get is:
{
"issues": [],
"errors": [
{
"status": 400,
"elementErrors": {
"errorMessages": [],
"errors": {
"issuelinks": "Field does not support update 'issuelinks'"
}
},
"failedElementNumber": 0
}
]
}
Does the API support the creation of Linked Issue at creation? Using the GUI works.
Jira is running v6.2.
Since this question is a bit older, I've been experiencing same issue as you. After some searching I found that instead of fields you can use update in the json you send to server.
Alternatively, you can use issueLink method to add links after creating the issue.
Complete code to create an issue with a link to a different issue:
{
"fields": {
"summary": "Sample Issue",
"project": {
"id": 14505
},
"issuetype": {
"id": 11002
}
},
"update": {
"issuelinks": [
{
"add": {
"type": {
"name": "Relates"
},
"inwardIssue": {
"key": "PRJ-1"
}
}
}
]
}
}
This will solve your problem. This will create an issue with one jira issue linked to it.
key is a project key,
Blocks or related to whichever you want.
put below json into http://jsonlint.com/. It will do proper formatting.
{
"fields": {
"summary": "Test Adapter",
"project": {
"key": "WFM"
},
"description": "Testing of Jira from Adapter",
"issuetype": {
"name": "Bug"
},
"update": {
"issuelinks": [{
"add": {
"type": {
"name": "Blocks",
"inward": "is blocked by",
"outward": "blocks"
},
"outwardIssue": {
"key": "WFM-28",
"fields": {
"summary": "Test Adapter"
}
}
}
}]
}
}
}