Is there any way to make POST request of API Blueprint to accept any value?
Right now I have:
### Google [POST]
Login with Google
+ token (string) - google token
+ Request (application/json)
{
"token": "google"
}
+ Response 200 (application/json)
{
"token": "xyz",
}
And nothing apart from exactly the same body as as described is being consumed by Drakov.
You can use schema, instead of hardcoded values.
Request(application/vnd.aconex.pdfmerge.job.v1.1+json)
Headers
Accept: application/vnd.pdfmerge.job.v1.1+json
Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"zipFilePath": {
"type": "string"
},
"status": {
"type": "string"
},
"mergedFilePath": {
"type": ["string", "null"]
},
"id": {
"type": "string"
},
"fileName": {
"type": "string"
}
},
"required": [
"zipFilePath",
"status",
"mergedFilePath",
"id",
"fileName"
]
}
Related
Working on sending email on http trigger with attachments in logic app. Providing json input as below
{
"properties": {
"bcc": {
"type": "string"
},
"body": {
"type": "string"
},
"cc": {
"type": "string"
},
"subject": {
"type": "string"
},
"to": {
"type": "string"
},
"attachments":{
"name":{
"type":"string"
},
"ContentBytes":{
"type":"string"
}
},
"type":"object"
},
"type": "object"
}
passing attachment in base64 string format.
But while configuring attachments for content variable getting an error
Unable to parse template language expression
'base64('triggerBody()?['contentBytes']')': expected token
'RightParenthesis' and actual 'Identifier'.".'
You need to click on Add dynamic content and use the following expression:
base64(triggerBody()?['attachments']?['ContentBytes'])
I'm using WireMock (Docker) docker.io/rodolpheche/wiremock:2.27.2-alpine. I set it up via Docker Compose and everything works flawlessly.
I'm trying to set up a stub/mapping to check the JSON input against the corresponding JSON schema. Basically, this is the stub/mapping:
{
"name": "Create Character Stub",
"request": {
"headers": {
"accept": {
"caseInsensitive": true,
"equalTo": "application/json"
},
"content-type": {
"caseInsensitive": true,
"equalTo": "application/json"
}
},
"method": "POST",
"url": "/api/characters",
"body": {
// [start] I made this up, but that's what I'm trying to achieve
"type": "JSON_SCHEMA",
"location": ""schemas/create-character.json""
// [end]
}
},
"response": {
"headers": {
"location": "{{ request.path }}/{{ randomValue type='UUID' }}"
},
"status": 201,
"transformers": ["response-template"]
}
}
...and this is (an excerpt of) the JSON schema:
{
"$schema": "http://json-schema.org/draft/2019-09/schema#",
"type": "object",
"description": "Character entity",
"properties": {
"first_name": {
"type": "string",
"description": ""
},
"last_name": {
"type": "string",
"description": ""
},
"age": {
"type": "number",
"description": ""
}
},
"additionalProperties": false,
"required": ["first_name", "last_name", "age"]
}
Is there a way to accomplish this with WireMock? I've been searching for something like that for a while. The closer I've found is to use JSON path, but that's not quite the same as checking for a proper schema — and could be tedious task with long JSON requests.
I searched through the issues in the WireMock's GitHub repository, but I can only see this one (closed by the way). Still, I don't see a way to do exactly what I'm looking for. I just have as input a JSON schema.
I have a logic app which gets Address info using Bind Rest Api. I received a nested json object. When I tried to parse it, I'm getting null values in dynamix syntax box.
Below is the json object that I get, however when I use these as properties after parsing, they are marked as null:
{
"address": {
"addressLine": "1-11-252, Begumpet Road",
"adminDistrict": "TS",
"adminDistrict2": "Hyderabad",
"countryRegion": "India",
"formattedAddress": "1-11-252, Begumpet Road, Hyderabad, TS 500016",
"intersection": {
"baseStreet": "Begumpet Road",
"secondaryStreet1": "Chikoti Garden No-4 Road",
"intersectionType": "Near",
"displayName": "Begumpet Road and Chikoti Garden No-4 Road"
},
"locality": "Hyderabad",
"neighborhood": "Begumpet",
"postalCode": "500016",
"countryRegionIso2": "IN"
}
}
Based on your information, here's what I did:
Created a Logic App in the Azure portal
Selected the "When a HTTP request is received" trigger
Clicked "Use sample payload to generate schema" link and pasted your example data (SEE BELOW!)
Added a "Response" action
Defined the response's body to be:
{
"address": baseStreet
}
Where baseStreet is a reference to the baseStreet dynamic content.
The result:
IMPORTANT!
Please be advised that the Request Body JSON Schema is different than the payload:
{
"type": "object",
"properties": {
"address": {
"type": "object",
"properties": {
"addressLine": {
"type": "string"
},
"adminDistrict": {
"type": "string"
},
"adminDistrict2": {
"type": "string"
},
"countryRegion": {
"type": "string"
},
"formattedAddress": {
"type": "string"
},
"intersection": {
"type": "object",
"properties": {
"baseStreet": {
"type": "string"
},
"secondaryStreet1": {
"type": "string"
},
"intersectionType": {
"type": "string"
},
"displayName": {
"type": "string"
}
}
},
"locality": {
"type": "string"
},
"neighborhood": {
"type": "string"
},
"postalCode": {
"type": "string"
},
"countryRegionIso2": {
"type": "string"
}
}
}
}
}
When running with the Parse JSON step:
Background
I have a custom connector which returns a JSON response .I am trying to parse the response to JSON since i want to use the response later in other flows. So that I am using Parse JSON Action from Data operations connector. Following is the JSON response and the JSON schema i provided to Parse JSON.
Response
[
[
{
"key":"Customer_Key",
"value":{
"id":"abfa48ad-392d-e511-80d3-005056b34214",
"name":"90033"
}
},
{
"key":"Status",
"value":"Done"
}
]
]
Schema
{
"type": "array",
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"required": [
"key",
"value"
]
}
}
}
Exception
{
"message": "Invalid type. Expected Object but got String.",
"lineNumber": 0,
"linePosition": 0,
"path": "[0][2].value",
"value": "90033",
"schemaId": "#/items/items/properties/value",
"errorType": "type",
"childErrors": []
},
Any one knows what is the issue on this ?How we can I convert above json response
Looks like the Use sample payload to generate schema couldn't generate right schema.
So you could go to this liquid studio site and paste the JSON payload then click the Generate Schema button, then you will get the Json Schema.
And I test the Schema, it worked perfectly.
Hope this could help you, if you still have other questions,please let me know.
Schema looks incorrect. try with the below schema:
{
"type": "array",
"items": [
{
"type": "array",
"items": [
{
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
]
}
},
"required": [
"key",
"value"
]
},
{
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value"
]
}
]
}
]
}
I am trying to write static .json file of server response using swagger. I'm stuck with post body and do not know how to describe it. It looks pretty much similar to Grooveshark api's where you have one page and different post parameters.
So, given grooveshark example (http://developers.grooveshark.com/docs/public_api/v3/)
Page that takes queries:
http://api.grooveshark.com/ws3.php?sig=cd3ccc949251e0ece014d620bbf306e7
POST body:
{
'method': 'addUserFavoriteSong',
'parameters': {'songID': 0},
'header': {
'wsKey': 'key',
'sessionID': 'sessionID'
}
}
How can I describe this with swagger?
without knowing a ton about how this API operates (such as, is "songID" the only parameter type?, I'm guessing you'd want something like this in your models section:
"models": {
"FavoriteSong": {
"id": "FavoriteSong",
"properties": {
"parameters": {
"type": "Parameter"
},
"header": {
"type": "Header"
}
}
},
"Parameter": {
"id": "Parameter",
"properties": {
"songID": {
"type": "integer",
"format": "int32"
}
}
}
"Header": {
"id": "Header",
"properties": {
"wsKey": {
"type": "string"
},
"sessionID": {
"type": "string"
}
}
}
}
}
And the operation would take the type "FavoriteSong" as a body type:
"parameters": [
{
"name": "body",
"description": "object to add",
"required": true,
"type": "FavoriteSong",
"paramType": "body"
}
]