+1

Any idea why I can't assign to a datasource source?

thillsman vor 11 Jahren aktualisiert vor 11 Jahren 3
I'm working on an app that uses Parse and I'm trying to query for the first time. I've got everything working with Postman (Chrome plug-in for HTTP requests) and it's pretty straightforward. Header is correct and in place (I use it for every other datasource). The request itself is just a URL parameter like this: BASEURL?where={"userid":"XXXXX"} I've narrowed my issue down to a very specific piece of code:


<action name="oninit" oninit="yes">
<assign property="var:url" value="https://api.parse.com/1/classes/data?where=&#123;&quot;userid&quot;:&quot;cB93EZSEzN&quot;&#125;" />
<alert message="VAR: [var:url]" />
<assign property="datasource:parsecheckdata.source" value="[var:url]" />
<alert message="DS: [datasource:parsecheckdata.source]" />
</action>


My first alert looks perfect. It shows the exact URL I want to send. My second alert is blank, so I'm guessing it's not writing to the datasource source for some reason.

I'd assumed it might be the curly braces, so I replaced them with the HTML entities { and } but it's still not working. Any idea?
Because this is happening oninit you might need to use a sync block so these aren't happening at the same time.
Hm, still no dice. Ironically, the debug console shows the source as being assigned to the URL, but with 0 results (there should be 2), and my querycomplete action never fires.
Here's the solution (thanks Marty, Ian, Adam, and John!):


<action name="oninit" oninit="yes">
<sync>
<assign property="var:params" value="where={&quot;userid&quot;:&quot;cB93EZSEzN&quot;}" encoding="url"/>
<assign property="datasource:parsecheckpets.source" value="https://api.parse.com/1/classes/pets?[var:params]" />
</sync>
</action>


The important thing here is the encoding. Parse wants the parameters URL-encoded. However, you don't want to encode the entire URL (http:// and all), because that breaks things.