Skip to content

Instantly share code, notes, and snippets.

@bithavoc
Last active December 10, 2015 23:30
Show Gist options
  • Save bithavoc/4509605 to your computer and use it in GitHub Desktop.
Save bithavoc/4509605 to your computer and use it in GitHub Desktop.
Command with Fauna Sub Requests
// POST /commands result
{
"resource" : {
"ref" : "commands/reply_message",
"ts" : 1357900098422864,
"name" : "reply_message",
"comment" : "Reply a Message",
"actions" : [ {
"method" : "POST",
"path" : "/v0/instances",
"body" : {
"class" : "message",
"data" : {
"body" : "$body"
}
}
}, {
"method" : "POST",
"path" : "/v0/classes/message/timelines/chat/",
"body" : {
"resource" : "${$0.resource.ref}"
}
} ],
"deleted" : false
},
"references" : { }
}
// result:
{
"error" : "Bad Request",
"param_errors" : {
"resource" : "Invalid resource ref."
}
}
@bithavoc
Copy link
Author

If I change it to:

"resource" : "$0.resource.ref"

Then the results is:

{
  "error" : "Bad Request",
  "param_errors" : {
    "resource" : "Failed to find element resource in 'JSON({\n  \"ref\" : \"instances/22692978309988352\",\n  \"ts\" : 1357900560578670,\n  \"class\" : \"message\",\n  \"user\" : \"users/20679000498110464\",\n  \"references\" : { },\n  \"data\" : { },\n  \"deleted\" : false\n})'"
  }
}

Now check my next comment...

@bithavoc
Copy link
Author

Notice how it's actually creating the resource:

\"ref\" : \"instances/22692978309988352\"

but it seems it couldn't find element "resource".... so I change it to:

"resource" : "$0.ref"

then it returns:

{
  "error" : "Not Found"
}

This one is a little hard to debug, there is no detail in the error. Why is the reference not valid?

@evan
Copy link

evan commented Jan 12, 2013

This is our fault. Fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment