+1
Respuestas
How can I query an item in the top level of a JSON datasource?
Ok, so I'm diving deep into Parse for a project, and I'm using the example that John provided here: https://getsatisfaction.com/rarewire/...
I'm sending data, creating users, and doing all kinds of cool things. However, I want to see the response from Parse. I can see the raw response with [datasource:parsePost.0.content], and that's cool, but I want to see each piece broken out. For example, a Parse error response looks like this:
In this case, I tried to create a user with an email address of "a". Ideally, I'd just grab the "code" element, and use an < if> statement to tell the user that they need to use a real email address (if the code is "125").
Unfortunately, the response doesn't have "code" and "error" wrapped in another element, so I'm unsure how to query it.
In John's example he used query="/result" and [datasource:parsePost.0.content], but neither [datasource:parsePost.0.code] and [datasource:parsePost.1.code] work. I've also tried query="", query="/", query="//", and query="//*[local-name()]"; all work for [datasource:parsePost.0.content], but none work for either of my guesses on how to grab only the "code" element.
Hopefully that wasn't too confusing. :)
I'm sending data, creating users, and doing all kinds of cool things. However, I want to see the response from Parse. I can see the raw response with [datasource:parsePost.0.content], and that's cool, but I want to see each piece broken out. For example, a Parse error response looks like this:
{
"code": 125,
"error": "invalid email a"
}
In this case, I tried to create a user with an email address of "a". Ideally, I'd just grab the "code" element, and use an < if> statement to tell the user that they need to use a real email address (if the code is "125").
Unfortunately, the response doesn't have "code" and "error" wrapped in another element, so I'm unsure how to query it.
In John's example he used query="/result" and [datasource:parsePost.0.content], but neither [datasource:parsePost.0.code] and [datasource:parsePost.1.code] work. I've also tried query="", query="/", query="//", and query="//*[local-name()]"; all work for [datasource:parsePost.0.content], but none work for either of my guesses on how to grab only the "code" element.
Hopefully that wasn't too confusing. :)
Servicio de atención al cliente por UserEcho
<wire>
<datasources>
<!-- add http header values the service needs here -->
<httpheader name="jsonheader" Accept="text/json"/>
<datasource name="validation" httpheader="jsonheader" source="" query="/" providertype="json" querycomplete="validate" httpmethod="post"/>
</datasources>
<main>
<!-- this text template contains the content you want to send to the service add [var:xxx] for variables etc -->
<texttemplate name="expired-receipt"><![CDATA[ {"format_version":1,"type":"email","email":{"to_email":"TO_ADDRESS","to_name":"TO_NAME","from_email":"FROM_EMAIL","from_name":"FROM_NAME","subject":"EMAIL_SUBJECT","body_html":"BODY_HTML_VERSION","body_text":"BODY_TEXT_VERSION"}}]]></texttemplate>
<panel name="body" height="50%" width="50%" background="#ff0000" valign="center" align="center">
</panel>
</main>
<actions>
<action name="start" oninit="yes">
<sync>
<!-- assign the value of the text template to the postContent property of the datasource to be sent to the server -->
<assign property="datasource:validation.postContent" value="[template:expired-receipt.content]" />
<!-- update the source of the ds to initiate the request -->
<assign property="datasource:validation.source" value="http://studio.rarewire.com/get-apple-subscription-data/D3mwuC8bvBWUXSnq" />
</sync>
</action>
<action name="validate">
<alert message="[datasource:validation.1.status]"/>
<assign property="var:status" value="[datasource:validation.1.status]" />
</action>
</actions>
</wire>
With the code above, all I have been getting is blank alerts...
Were you able to get what you needed here once you encoded the & in your source? Or are you still having issues?