I'm trying to make a custom YQL table to access a user's likes through the Tumblr API. I made the following table in the YQL editor and saved it as tumblr.likes:
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>nonphoto</author>
<documentationURL>http://www.tumblr.com/docs/api</documentationURL>
<sampleQuery>select * from {table} where username='XXX' api_key='XXX'</sampleQuery>
</meta>
<bindings>
<select itemPath="response.liked_posts" produces="JSON">
<urls>
<url>http://api.tumblr.com/v2/blog/{username}.tumblr.com/likes</url>
</urls>
<inputs>
<key id="username" type="xs:string" paramType="path" required="true" />
<key id="api_key" type="xs:string" paramType="query" required="true" />
</inputs>
</select>
</bindings>
</table>
If this is correct then I should be able to type this query into the YQL console and get a JSON response back from Tumblr:
use "XXX" as tumblr.likes;
select * from tumblr.likes where username='XXX' and api_key='XXX';
But null appears in the results entry of the response, even if debug and diagnostics are checked to prevent caching. The response even shows the correct URL, which works if I just copy and paste it into my browser. Am I missing something? Here's an example response:
{
"query": {
"count": 0,
"created": "2016-01-15T21:44:36Z",
"lang": "en-US",
"diagnostics": {
"url": [
{
"execution-start-time": "2",
"execution-stop-time": "8",
"execution-time": "6",
"id": "579e13ad-a7c3-4eea-81d9-41fda5caf243",
"content": "http://sherpa-bcp5903.dht.yahoo.com:4080/YDHTWebService/V1/get/yql.global/store%3A%2F%2FoSSGByQMlFLQhMqNCwUcp1"
},
{
"execution-start-time": "14",
"execution-stop-time": "1137",
"execution-time": "1123",
"id": "ffab25db-521f-4795-9220-a82e2ac33a9d",
"content": "http://api.tumblr.com/v2/blog/XXX.tumblr.com/likes?api_key=XXX"
}
],
"publiclyCallable": "true",
"user-time": "1146",
"service-time": "1129",
"build-version": "0.2.942"
},
"results": null
}
}
Related
I am using a payload mediator in the workflow to Update my JSON payload. I have successfully updated the payload with incoming request values and return output in JSON only. But in my JSON response payload after payload mediator, I am getting [ Value ] for the JSON element against which I have updated values.
I did not want my JSON element value enclosed within [] braces. I want a simple output like element: "Value".
Below is my JSON Response I receive after using the Payload mediator. Please guide me on how can I achieve the required output.
{
"FIXML": {
"Header": {
"RequestHeader": {
"MessageKey": {
"RequestUUID": [
"FEBA_1553756445880"
],
"ServiceRequestId": "executeFinacleScript",
"ServiceRequestVersion": "10.2",
"ChannelId": "COR"
},
"RequestMessageInfo": {
"BankId": [
"04"
],
"TimeZone": "GMT+05:00",
"EntityId": "",
"EntityType": "",
"ArmCorrelationId": "",
"MessageDateTime": 2020-03-03T16: 59: 10.000
},
"Security": {
"Token": {
"PasswordToken": {
"UserId": "11111",
"Password": ""
}
},
"FICertToken": "",
"RealUserLoginSessionId": "",
"RealUser": "",
"RealUserPwd": "",
"SSOTransferToken": ""
}
}
},
"Body": {
"executeFinacleScriptRequest": {
"ExecuteFinacleScriptInputVO": {
"requestId": [
"validateAcct.scr"
]
},
"executeFinacleScript_CustomData": {
"ACCT_NUM": [
"01122507578"
],
"PHONE_NUM": [
"59887834"
],
"NIC": [
"G2105493001653"
]
}
}
}
}
}
Conversion of Above JSON into XML as below.
<?xml version="1.0" encoding="UTF-8"?>
<FIXML>
<Body>
<executeFinacleScriptRequest>
<ExecuteFinacleScriptInputVO>
<requestId>
<element>validateAcct.scr</element>
</requestId>
</ExecuteFinacleScriptInputVO>
<executeFinacleScript_CustomData>
<ACCT_NUM>
<element>01122507578</element>
</ACCT_NUM>
<NIC>
<element>G2105493001653</element>
</NIC>
<PHONE_NUM>
<element>59887834</element>
</PHONE_NUM>
</executeFinacleScript_CustomData>
</executeFinacleScriptRequest>
</Body>
<Header>
<RequestHeader>
<MessageKey>
<ChannelId>COR</ChannelId>
<RequestUUID>
<element>FEBA_1553756445880</element>
</RequestUUID>
<ServiceRequestId>executeFinacleScript</ServiceRequestId>
<ServiceRequestVersion>10.2</ServiceRequestVersion>
</MessageKey>
<RequestMessageInfo>
<ArmCorrelationId />
<BankId>
<element>04</element>
</BankId>
<EntityId />
<EntityType />
<MessageDateTime>2020-03-03T18:31:48.000</MessageDateTime>
<TimeZone>GMT+05:00</TimeZone>
</RequestMessageInfo>
<Security>
<FICertToken />
<RealUser />
<RealUserLoginSessionId />
<RealUserPwd />
<SSOTransferToken />
<Token>
<PasswordToken>
<Password />
<UserId>11111</UserId>
</PasswordToken>
</Token>
</Security>
</RequestHeader>
</Header>
</FIXML>
Both JSON and XML files are used as Input and Output to Data mapper. But After data when I logged the message I get empty XML as below.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<FIXML>
<Body>
<executeFinacleScriptRequest>
<ExecuteFinacleScriptInputVO>
<requestId>
<element />
</requestId>
</ExecuteFinacleScriptInputVO>
<executeFinacleScript_CustomData>
<ACCT_NUM>
<element />
</ACCT_NUM>
<NIC>
<element />
</NIC>
<PHONE_NUM>
<element />
</PHONE_NUM>
</executeFinacleScript_CustomData>
</executeFinacleScriptRequest>
</Body>
<Header>
<RequestHeader>
<MessageKey>
<ChannelId />
<RequestUUID>
<element />
</RequestUUID>
<ServiceRequestId />
<ServiceRequestVersion />
</MessageKey>
<RequestMessageInfo>
<ArmCorrelationId />
<BankId>
<element />
</BankId>
<EntityId />
<EntityType />
<MessageDateTime />
<TimeZone />
</RequestMessageInfo>
<Security>
<FICertToken />
<RealUser />
<RealUserLoginSessionId />
<RealUserPwd />
<SSOTransferToken />
<Token>
<PasswordToken>
<Password />
<UserId />
</PasswordToken>
</Token>
</Security>
</RequestHeader>
</Header>
</FIXML>
</soapenv:Body>
</soapenv:Envelope>
Please Guide me here. How this conversion is properly done.
I want to convert my XML data to JSON using data mapper. But when I have added mapper in ESB flow and provide XML input and JSON output. It says DataMapper mediator: mapping failed. Please guide me on what is wrong with XML and JSON?
My XML input as below:-
<?xml version="1.0" encoding="UTF-8"?>
<FIXMLResponse xmlns="http://www.finacle.com/fixml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<ResponseHeader>
<RequestMessageKey>
<RequestUUID>FEBA_1553756445880</RequestUUID>
<ServiceRequestId>executeFinacleScript</ServiceRequestId>
<ServiceRequestVersion>10.2</ServiceRequestVersion>
<ChannelId>COR</ChannelId>
</RequestMessageKey>
<ResponseMessageInfo>
<BankId>04</BankId>
<TimeZone>System.CurrentSystemTimeZone</TimeZone>
<MessageDateTime>2020-02-27T20:25:13.697653+05:30</MessageDateTime>
</ResponseMessageInfo>
<UBUSTransaction>
<Id />
<Status />
</UBUSTransaction>
<HostTransaction>
<Id />
<Status>SUCCESS</Status>
</HostTransaction>
<HostParentTransaction>
<Id />
<Status />
</HostParentTransaction>
</ResponseHeader>
</Header>
<Body>
<executeFinacleScriptResponse>
<ExecuteFinacleScriptOutputVO xsi:type="xsd:string" />
<executeFinacleScript_CustomData>
<STATUS>SUCCESS</STATUS>
<ERROR>
<FIBUSINESSEXCEPTION>
<ERRORDETAIL>
<ERRORCODE>ERR0008</ERRORCODE>
<ERRORDESC>Invalid NIC Passed</ERRORDESC>
<ERRORTYPE>BE</ERRORTYPE>
</ERRORDETAIL>
</FIBUSINESSEXCEPTION>
</ERROR>
</executeFinacleScript_CustomData>
</executeFinacleScriptResponse>
</Body>
</FIXMLResponse>
My JSON Output (conversion of above XML into JSON using online tool) as below:-
{
"Header": {
"ResponseHeader": {
"RequestMessageKey": {
"RequestUUID": "FEBA_1553756445880",
"ServiceRequestId": "executeFinacleScript",
"ServiceRequestVersion": "10.2",
"ChannelId": "COR"
},
"ResponseMessageInfo": {
"BankId": "04",
"TimeZone": "System.CurrentSystemTimeZone",
"MessageDateTime": "2020-02-27T20:25:13.697653+05:30"
},
"UBUSTransaction": {
"Id": null,
"Status": null
},
"HostTransaction": {
"Id": null,
"Status": "SUCCESS"
},
"HostParentTransaction": {
"Id": null,
"Status": null
}
}
},
"Body": {
"executeFinacleScriptResponse": {
"ExecuteFinacleScriptOutputVO": {
"#type": "xsd:string"
},
"executeFinacleScript_CustomData": {
"STATUS": "SUCCESS",
"ERROR": {
"FIBUSINESSEXCEPTION": {
"ERRORDETAIL": {
"ERRORCODE": "ERR0008",
"ERRORDESC": "Invalid NIC Passed",
"ERRORTYPE": "BE"
}
}
}
}
}
}
}
If you just want to do a XML to JSON transformation without customising any values, you can use messageType property to convert and get the response. Look at the sample proxy configuration below.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="tojson"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
If you send the XML payload to this proxy, it will send a JSON response.
I am working on a medical application based on HL7 FHIR. I am trying to add new record using XML and JSON both. But all I get is the '500 Internal Server Error'.
The XML I am trying to POST is:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Patient Data</title>
<id>urn:uuid:20</id>
<updated>2015-05-21T16:33:58.030533</updated>
<entry>
<title>Patient Dummy Data</title>
<id>Other/p21-disease-activity-score-1439917023</id>
<updated>2015-08-18T18:57:03</updated>
<published>2015-08-18T18:57:03</published>
<content type="text/xml">
<Other xmlns="http://hl7.org/fhir">
<identifier>
<value value="p21-disease-activity-score-1439917023" />
</identifier>
<text>
<status value="generated" />
</text>
<subject>
<reference value="patient/21" />
<display value="4" />
</subject>
<code>
<coding>
<system value="http://hl7.org/fhir/other-resource-type" />
<code value="RA_DISEASE_ACTIVITY" />
</coding>
</code>
</Other>
</content>
</entry>
</feed>
I am posting this XML to API Server using PHP-CURL but getting 500 Internal Server Error.
I tried with JSON too but no luck. Here is the JSON:
[
{
"resourceType": "Bundle",
"title": "PatientData",
"id": "urn:uuid:21",
"updated": "2015-05-21T16:33:58.030533",
"entry": [
{
"title": "MyTitle",
"id": "Other/p007-shoulder-lt-1439220540",
"updated": "2015-08-10T11:29:00",
"published": "2015-08-10T11:29:00",
"author": {
"name": "Medtak"
},
"content": {
"resourceType": "Other",
"identifier": "007",
"text": {
"status": "generated"
},
"subject": {
"reference": "patient/007",
"display": "true"
},
"code": {
"coding": [
{
"system": "http://hl7.org/fhir/other-resource-type",
"code": "RA_DISEASE_ACTIVITY"
}
]
}
}
}
]
}
]
I have spent almost 3 days to fix this issue but couldn't find any solution. Any help would be appreciated. Thanks!
POST a resource via CURL
curl -X POST https://api.1uphealth.care/fhir/stu2/Patient \
-H "Content-Type: application/json" \
-H "Authorization: Bearer xxx_your_access_token_here_xxx" \
-d '{"resourceType": "Patient","id": "helloiamatestpatient","gender": "female"}'
If you're posting xml, use the correct xml fhir doc and change the Content-Type.
Depending on the FHIR server you're working with, you may not be able to POST resources because many do not support write access yet.
Here's some more information on using oauth to query FHIR - https://1up.health/dev/intro-fhir-api-oauth-query
You can get some idea if you following below link.
http://hl7-fhir.github.io/overview-dev.html
With cars-jpa-archetype example, I am able to perform deep insert (Car and
Driver) in XML but not JSON. With my JSON 1 or 2 at below, only Car is
inserted and Driver is null. Any one can shed light on my JSON inputs? Have no issue with JSON input if I use Olingo annotations (#EdmEntityType etc).
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="
http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="
http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="
http://localhost:8080/example/MyFormula.svc/">
<category term="MyFormula.Car" scheme="
http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link href="Cars(Id=553,IdL=554L)" rel="edit" title="Car" />
<link href="Cars(Id=553,IdL=554L)/DriverDetails" rel="
http://schemas.microsoft.com/ado/2007/08/dataservices/related/DriverDetails"
title="DriverDetails" type="application/atom+xml;type=entry">
<m:inline>
<entry xml:base="http://localhost:8080/example/MyFormula.svc/">
<category term="MyFormula.Driver" scheme="
http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link href="Drivers(10L)" rel="edit" title="Driver" />
<link href="Drivers(10L)/CarDetails" rel="
http://schemas.microsoft.com/ado/2007/08/dataservices/related/CarDetails"
title="CarDetails" type="application/atom+xml;type=entry" />
<content type="application/xml">
<m:properties>
<d:Birthday>2014-12-05T14:35:11.141</d:Birthday>
<d:Id>10</d:Id>
<d:Lastname>Super</d:Lastname>
<d:Name>Speeder</d:Name>
<d:Nickname>TN</d:Nickname>
</m:properties>
</content>
</entry>
</m:inline>
</link>
<content type="application/xml">
<m:properties>
<d:Id>553</d:Id>
<d:IdL>554</d:IdL>
<d:Model>M1</d:Model>
<d:ModelYear>2014</d:ModelYear>
<d:Price>20000.0</d:Price>
<d:Updated>2014-03-20T14:35:17.075</d:Updated>
</m:properties>
</content>
</entry>
// JSON 1
{
"Id":677,
"IdL":"678",
"Model":"M1",
"ModelYear":2014,
"Price":"20000.0",
"Updated":"\/Date(1395326117075)\/",
"DriverDetails":{
"Birthday":"\/Date(1417790111141)\/",
"Id":"3",
"Lastname":"Super",
"Name":"Speeder",
"Nickname":"YZ",
"CarDetails": {
"__deferred": {
"uri": "
http://localhost:8080/example/MyFormula.svc/Drivers(3)/CarDetails"
}
}
}
}
// JSON 2
{
"d": {
"__metadata": {
"type": "MyFormula.Car"
},
"Id": 601,
"IdL": "602",
"Model": "M1",
"ModelYear": 2014,
"Price": "20000.0",
"Updated": "/Date(1395244800000)/",
"DriverDetails": {
"__metadata": {
"id": "http://localhost:8080/example/MyFormula.svc/Drivers(11L)",
"uri": "http://localhost:8080/example/MyFormula.svc/Drivers(11L)",
"type": "MyFormula.Driver"
},
"Birthday": "/Date(1417795200000)/",
"Id": "11",
"Lastname": "Super",
"Name": "Speeder",
"Nickname": "Bolt",
"CarDetails": {
"__deferred": {
"uri": "
http://localhost:8080/example/MyFormula.svc/Drivers(11L)/CarDetails"
}
}
}
}
}
Sorry for cross post here as no response from the Olingo forum.
Seems like the same issue was posted on their Jira but it should have been resolved now:
https://issues.apache.org/jira/browse/OLINGO-515
I'm writing an API that accesses bible passages from http://labs.bible.org/, and the JSON responses come back without a "response" header, or any hierarchy names. Firebug is showing that my GET requests come back as 200 status, but the response tab is always empty. If I type the url directly into the browser I get the results I want, but I don't know how to handle the JSON like that. Example: http://labs.bible.org/api/?passage=luke+9&formatting=full&type=json.
This is what the JSON looks like.
[
{
"bookname": "Luke",
"chapter": "9",
"verse": "1",
"text": "<t /><p class=\"bodytext\">After<n id=\"1\" /> Jesus<n id=\"2\" /> called<n id=\"3\" /> the twelve<n id=\"4\" /> together, he gave them power and authority over all demons and to cure<n id=\"5\" /> diseases,",
"title": "The Sending of the Twelve Apostles"
},
{
"bookname": "Luke",
"chapter": "9",
"verse": "2",
"text": "and he sent<n id=\"1\" /> them out to proclaim<n id=\"2\" /> the kingdom of God<n id=\"3\" /> and to heal the sick.<n id=\"4\" />"
},
{
"bookname": "Luke",
"chapter": "9",
"verse": "3",
"text": "He<n id=\"1\" /> said to them, “Take nothing for your<n id=\"2\" /> journey – no staff,<n id=\"3\" /> no bag,<n id=\"4\" /> no bread, no money, and do not take an extra tunic.<n id=\"5\" />"
},
{
"bookname": "Luke",
"chapter": "9",
"verse": "4",
"text": "Whatever<n id=\"1\" /> house you enter, stay there<n id=\"2\" /> until you leave the area.<n id=\"3\" />"
},
{
"bookname": "Luke",
"chapter": "9",
"verse": "5",
"text": "Wherever<n id=\"1\" /> they do not receive you,<n id=\"2\" /> as you leave that town,<n id=\"3\" /> shake the dust off<n id=\"4\" /> your feet as a testimony against them.”"
},
{
"bookname": "Luke",
"chapter": "9",
"verse": "6",
"text": "Then<n id=\"1\" /> they departed and went throughout<n id=\"2\" /> the villages, proclaiming the good news<n id=\"3\" /> and healing people everywhere.</p>"
},
{
"bookname": "Luke",
"chapter": "9",
"verse": "7",
"text": "<t /><p class=\"bodytext\">Now Herod<n id=\"1\" /> the tetrarch<n id=\"2\" /> heard about everything that was happening, and he was thoroughly perplexed,<n id=\"3\" /> because some people were saying that John<n id=\"4\" /> had been raised from the dead,",
"title": "Herod’s Confusion about Jesus"
},
(...)
]
So how do I write the code to access and parse the JSON, and how would I cycle through all the results?
These are my functions for getting and parsing the JSON:
function callApi(argument, callBack){
var requestUrl = apiUrl+argument+type;
try{
var request = new XMLHttpRequest();
request.addEventListener("readystatechange",
function() {callBack(request);}, false);
request.open("GET", requestUrl, true);
request.setRequestHeader("Accept", "application/json; charset=utf-8");
request.send();
}//end try
catch(exception){
alert("Request Failed");
}//end catch
}//end function callApi
function parseData(request){
if(request.readyState==4 && request.status==200){
var data = JSON.parse(request.responseText);
displayNames(data);
}//end if
}// end function parseData
What if you were to try using a different JSON URL like this: http://labs.bible.org/api/?passage=luke+9:3&type=json&callback=? (removing &formatting=full and adding &callback=? at the end.)
If you get the response without the formatting tags (all of the <HTML> tags) it seems to parse for me, at least in this example on jsFiddle:
http://jsfiddle.net/L8Fed/2/
Update: Here is an example of how jQuery could be used here to grab the JSON from your URL:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function() {
var json_url = "http://labs.bible.org/api/?passage=luke+9:3&type=json&callback=?";
$.getJSON(json_url, function(json_response) {
for(var i = 0; i < json_response.length; i++) {
alert(json_response[i].text);
}
});
});
</script>
Basically, this code:
Includes jQuery
Puts the JavaScript into the ready function (more details here...)
Makes sure to call the API URL that includes the &callback=? at the end (for this reason)
Calls jQuery's $.getJSON() function (that uses your API URL and gets the response back named json_response)
Loops through the json_response and allows you to get whatever values you need. (And you'll probably want to take out the alert() function at some point... ;)