I'm attempting to add the data from action_fields to the bundle.request.url as a querystring. Here is raw bundle data
{
"auth_fields": {
"sub_domain": "abc",
"apiKey": "1234"
},
"request": {
"files": {},
"url": "https://abc.my.workfront.com/attask/api/v7.0/project?&method=post",
"headers": {
"Content-Type": "application/json; charset=utf-8",
"Accept": "application/json"
},
"params": {
"apiKey": "1234"
},
"data": "{\"status\": \"PLN\", \"name\": \"Test 2\"}",
"method": "POST"
},
"action_fields": {
"status": "PLN",
"name": "Test 2"
},
"action_fields_full": {
"status": "PLN",
"name": "Test 2"
},
"meta": {
"frontend": false
},
"action_fields_raw": {
"status": "PLN",
"name": "Test 2"
},
"url_raw": "https://{{sub_domain}}.my.workfront.com/attask/api/v7.0/project?&method=post",
"zap": {}
}
I'm working off of an example Zapier provides and came up with this
'use strict';
var Zap = {
project_pre_write: function(bundle) {
// bundle.request.method = "POST";
console.log(bundle.request.action_fields["status"]);
bundle.request.url = "http://abc.my.workfront.com/attask/api/v8.0/project?method=post";
bundle.request.params = $.param(bundle.request.action_fields);
console.log(bundle.request.params);
return bundle.request;
}
};
But I have this error thrown
TypeError: Cannot read property 'jquery' of undefined:
I'm no Javascript expert (barely even a user) so any thoughts would be appreciated. The end result should look like this
http://abc.my.wrokfront.com/attask/api/v7.0/project?method=post&name=Test%202&status=PLN&apiKey=1234
Try this:
bundle.request.url += '&' + jQuery.param(bundle.action_fields);
Related
I'm trying to fetch data from an AWS DataExchange provider based on their company's API specification.
I'm using the AWS Node.JS NPM modules 'aws-sdk' and '#aws-sdk/client-dataexchange'.
However, every query I've written is returning the error '404: Asset not found'.
I'm subscribed to use the API and I've verified that all my AWS credentials, policies and IAM keys give me permission to access the API.
Could someone please help me identify what's wrong with my query in relation to the API specification.
Thanks!
The response I get looks like below:
404: Asset not found
'$fault': 'client',
'$metadata': {
httpStatusCode: 404,
requestId: 'b7e6e691-xxxxxxx7657201138a4',
extendedRequestId: undefined,
cfId: 'dBQBwlCE8cXp4--xxxxxxxxxxx3j2lTfxywUezCPEA6nusJCJg==',
attempts: 1,
totalRetryDelay: 0
},
ResourceType: 'ASSET',
ResourceId: 'e055c882bde1fa3xxxxxxxxx'
}
My current request 'body' looks like below:
Body: JSON.stringify({
"description": "GraphQL query for the Ursa Space Imagery Catalog.",
"content": {
"application/graphql": {
"schema": {
"$ref": "#/components/schemas/CatalogSearchRequest"
},
"query": {
"description": "Limit the number of records in a response.",
"value":"{\n availablemetadatarecord(\n limit: 20\n content: { catalogProperties: { vendor: { eq: \"ICEYE\" } } }\n ) {\n assignedId\n }\n}\n"
}
}
},
"required": true
}),
The DataExchange provider's actual API specification looks like below:
{
"openapi": "3.0.1",
"info": {
"title": "image-services",
"description": "API Gateway for integration of Platform Services into AWS Data Exchange",
"version": "2022-03-03T20:04:18Z"
},
"servers": [
{
"url": ""
}
],
"paths": {
"/psdm/graphql": {
"post": {
"requestBody": {
"description": "GraphQL query for the Catalog in the form of:\n\n `{\n availablemetadatarecord(\n QUERYPARAMS\n ) { \n FIELDLIST\n } \n }`\n",
"content": {
"application/graphql": {
"schema": {
"$ref": "#/components/schemas/CatalogSearchRequest"
},
"examples": {
"Limit returned data": {
"description": "Limit the number of records in a response.\n\nIn your query, simply specify `limit: <int>` \n",
"value": "{\n availablemetadatarecord(\n limit: 10\n content: { catalogProperties: { vendor: { eq: \"EYE\" } } }\n ) {\n assignedId\n }\n}\n"
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CatalogSearchResponse"
}
}
}
}
},
"security": [
{
"sigv4": []
}
]
}
}
},
"components": {
"schemas": {
"CatalogSearchRequest": {
"title": "CatalogSearchRequest",
"type": "object"
},
"CatalogSearchResponse": {
"title": "Catalog Search Response",
"required": [
"data",
"paginationInfo"
],
"type": "object",
"properties": {
"paginationInfo": {
"type": "object",
"properties": {
"recordsInPage": {
"type": "integer"
},
"nextOffset": {
"type": "integer"
}
}
},
"data": {
"type": "object",
"properties": {
"availablemetadatarecord": {
"type": "array",
"description": "Records returned by query",
"items": {
"type": "object"
}
}
}
}
}
}
},
"securitySchemes": {
"sigv4": {
"type": "apiKey",
"name": "Authorization",
"in": "header",
"x-amazon-apigateway-authtype": "awsSigv4"
}
}
}
}
I would like to construct a dynamic json and do a post call. I am using ${data.list.name} to get the value from an object but it is not working. Is there a way to do this?
function callTeams (data) {
fetch(WEBHOOK, {
'method': 'POST',
'headers': { 'Content-Type': 'application/json' },
'body': JSON.stringify({
"#type": "MessageCard",
"#context": "http://schema.org/extensions",
"themeColor": "0076D7",
"sections": [{
"activityTitle": "${data.list.name} is valid",
"activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
"facts": [ {
"name": "Key",
"value": "${data.list.name}"
}],
"markdown": true
}],
"potentialAction": [ {
"#type": "OpenUri",
"name": "Submit",
"targets": [{
"os": "default",
"uri": "https://learn.microsoft.com/outlook/actionable-messages"
}]
}]
})
})
}
Use template literals. Replace things like
{
"activityTitle": "${data.list.name} is valid"
}
with
{
"activityTitle": `${data.list.name} is valid`
}
In other words, use backticks (`)
My team is building a health app and thus using Asymmetrik FHIR API Server. We need to save a bundle consisting of Condition, Observation and Procedure. The bundle should create each individual object in their respective tables. But when we are using postman to hit the base URL with a very simple bundle object it is giving Invalid URL. Each service is individually working fine and able to create respective objects. How can we enable the root URL of this FHIR server?
POST URL: http://localhost:3000/4_0_0/
POST Object:
{
"resourceType": "Bundle",
"id": "f001",
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "Observation",
"status": "registered"
},
"request": {
"method": "POST",
"url": "Observation"
}
},
{
"resource": {
"resourceType": "Condition",
"code": {
"coding": {
"system": "http://hl7.org/fhir/ValueSet/condition-code",
"code": "",
"display": ""
}
}
},
"request": {
"method": "POST",
"url": "Condition"
}
}
]
}
ERROR:
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "not-found",
"details": {
"text": "Invalid url: /4_0_0/"
}
}
]
}
I have a swagger tag document using the Swagger UI that always returns text/html but it should return application/json. The POST requests and every other type returns application/json but this particular GET request does not. The service end point code is correct. And if I change the request to POST it does return as application/json. So it is just type GET within swagger which does not return the correct type. Any thoughts how to correct the call within the UI to use the application/json?
This is swagger version 2.1.4 that was downloaded recently from the swagger site.
"/bankName": {
"get": {
"summary": "Bank Name Search",
"description": "Bank Name Search, input routing number to return bank name",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "query",
"name": "routingNumber",
"description": "Input Bank Routing Number",
"required": true,
"type": "string",
}
],
"responses": {
"200": {
"description": "An array",
"schema": {
"type": "object",
"properties": {
"errorInfo": {
"$ref": "#/definitions/ErrorInfo"
},
"bankName": {
"type": "string",
}
}
}
},
"400": {
"description": "Invalid Request Input supplied"
},
"500": {
"description": "General Unexpected Error"
}
}
}
}
Accept:application/json
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Host:localhost:9086
Origin:http://localhost:9086
Pragma:no-cache
Referer:http://localhost:9086/swagger/index.html
Here is the Java code Spring Restful definition:
#RequestMapping(value="bankName",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
Have you tried this?
"/bankName": {
"get": {
"summary": "Bank Name Search",
"description": "Bank Name Search, input routing number to return bank name",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "query",
"name": "routingNumber",
"description": "Input Bank Routing Number",
"required": true,
"type": "string",
}
],
"responses": {
"200": {
"description": "An array",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"errorInfo": {
"$ref": "#/definitions/ErrorInfo"
},
"bankName": {
"type": "string",
}
}
}
}
}
},
"400": {
"description": "Invalid Request Input supplied"
},
"500": {
"description": "General Unexpected Error"
}
}
}
}
I am using javascript api to get facebook comments.
i am getting the following json result , but how can i parse them to use on my page ?
{
"id": "1234567891_2823098717038_3160191",
"from": {
"name": "User",
"id": "1234567891"
},
"message": "comment only...",
"can_remove": true,
"created_time": "2012-05-05T07:43:11+0000"
},
{
"id": "1234567891_2823098717038_3160281",
"from": {
"name": "User",
"id": "1234567891"
},
"message": "just another comment...",
"can_remove": true,
"created_time": "2012-05-05T08:14:17+0000"
},
{
"id": "1234567891_2823098717038_3160336",
"from": {
"name": "user2",
"id": "56265654845454"
},
"message": "congratz dear :)",
"can_remove": true,
"created_time": "2012-05-05T08:29:05+0000"
}
],
"paging": {
"next": "http://link.dddd"
}
}
How can i loop through this and display the contents ?
jQuery solution is acceptable.
Thank you.
Use JQuery.parseJSON: http://api.jquery.com/jQuery.parseJSON/
assoc_data = jQuery.param(response); //where response is your json
$.ajax({
type: "POST",
url: "submit_fb_data.php",
data: assoc_data,
success: function(data) {
//etc
}
});
make sure you use a >=1.4 jquery version