I would like to obtain in a response of http-connector, only the “number” element, but I cannot obtain it.
I’m trying to have an inline Javascript with the following statement:
S(response).prop(“status”).prop(“number”).numberValue();
but it shows an error: SPIN/JACKSON-JSON-01004 Unable to find ‘status’
What it’s wrong in the statement?
Rest response to parse:
{
“status”: {
“number”: 200,
“type”: “OK”,
“description”: “Status OK”
}
}
There is no obvious issue with your expression. I would debug further to see if response indeed contanis the Json string you posted. The error shows that response exists, but the content differs.
This working example I just created may help you:
https://github.com/rob2universe/camunda-http-connector-example
If this does not help, you could share more info, e.g. the process model, server log, service you are calling...
I have clone the example "todo-list" from github and without modifying anything the #post todo-lists is created without. then I use the responsed "Id" to #post /todo-lists/{id}/todos and it gave error
Unhandled error in POST /todo-lists/3/todos: 500 Error: Property "todoListId" cannot be changed!
at Object.constrainDataObject (D:\Projects\NodeJs\lbex\loopback4-example-todo-list\node_modules#loopback\repository\dist\repositor
ies\constraint-utils.js:49:19)
at DefaultHasManyRepository.create (D:\Projects\NodeJs\lbex\loopback4-example-todo-list\node_modules#loopback\repository\dist\rela
tions\has-many\has-many.repository.js:21:59)
at process._tickCallback (internal/process/next_tick.js:68:7)
I also tried to create everything by myself following the example.
https://loopback.io/doc/en/lb4/HasMany-relation.html
It sill give the same error.
PS. I have posted this on the loopback github but I don't know if that's the right place to post. So, I posted it here instead.
You must be sending todoListId in the request body. Remove that. Loopback juggler automatically attaches that value upon saving.
Below request body worked for me.
{
"title": "Testing 123",
"desc": "This is a testing description",
"isComplete": true
}
I am using post man to send a post request with the body as form-data which contains files and text. See the image below:
I want to json.stringify the entire body but I cannot work out how to do this in a pre-request script. As an environment variable can only be one part of the body further having files makes it more tricky.
I am not sure I understand the problem. In postman the request is a JavaScript object. If you are trying to stringify the request, I assume you are trying to get this:
propertyOne=valueOne&propertyTwo=ValueTwo
out of this:
const request = {
propertyOne: 'valueOne',
propertyTwo: 'ValueTwo'
};
The simple way is just to iterate the object's properties and write into an string:
function stringifyRequest(object) {
let resultString = '';
for (var property in object) {
if (object.hasOwnProperty(property)) {
let tempString = `${property}=${object[property]}`;
resultString = resultString ? `${resultString}&${tempString}` : tempString;
}
}
return resultString
}
Now, if you want to get the binary of the file you are uploading, it will not be possible. As seen in this thread:
We don't give access to the contents of the files in pre-request
scripts, for a few reasons.
We want to delay loading file contents to right before the request
is sent.
The request body is not actually resolved until the pre request
scripts are completed. So even if we wanted to we can't give the
actual body of the request in pre-request scripts.
They may eventually change that, but I could not find any indications of it. One user in this thread suggests using insomnia, you could check it out if fits your needs better.
the bash command I used to connect the bot is: curl -ik -X POST 'https://graph.facebook.com/v2.6/me/messages?access_token=#AccessToken'
My error message is:
{"error":{"message":"(#100) The parameter recipient is
required","type":"OAuthException","code":100,"fbtrace_id":"EFqWAGq2ABs"}}
Do anyone how to solve it ?
Just in case anyone missed this, I encountered this issue when I accidentally use the wrong content type - I was using application/x-www-form-urlencoded instead of application/json
So my advise overall is,
Check if you are indeed passing the parameter
Double check the characters and encoding
Make sure to use the correct endpoint
and Make sure to use the correct content type when posting the JSON Request.
You need to send the recipient id param. Try:
curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{"id":"YOUR RECIPIENT ID" }, "message":{ "text":"hello from bot" }}' "https://graph.facebook.com/v2.6/me/messages?access_token=YOUR_ACCESSTOKEN"
Best regards.
There is another reason for this error message: when you send incorrect characters (like a -tab-) Facebook return this error as well so check your return text on special chars.
Please use the "thread_settings" endpoint "https://graph.facebook.com/v2.6/me/thread_settings" as your API endpoint.
You are using the messages endpoint.
It comes down to the logic of your bot. I got this error as well just recently and it took me days to debug it. The problem for me was I called the callSendAPI(messageData) method outside of the function that compiled the messageData object.
Obviously, passing messageData outside of the function that compiles it sends an empty object instead of the compiled one. Thus the error message (#100) The parameter recipient is required. Simply because the empty object doesn't have any receipientId defined.
Please check your code's logic to ensure you didn't do the same mistake as I. Hope this helps :) Happy programming.
The endpoint is wrong. Instead of https://graph.facebook.com/v2.6/me/messages?access_token=#AccessToken, use this endpoint
https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>
This happens when we do not read the documentation., the info is right here https://developers.facebook.com/docs/messenger-platform/discovery/welcome-screen#,
right under the "Setting the Get Started Button Postback".
I got similar error some time back. Try using Postman. I tried the same request and replaced the user id and the page access token. It works fine.
Click on the Import button on the top and paste your curl request under raw. Then try running the call. If you get the same error, go to the body and modify it. Make sure you put this in the body part of the Postman request. Replace the recipient id with yours.
{
"recipient":
{
"id":"123456789"
},
"message":
{
"text":"hello, world!"
}
}
This is the full cURL call : Change Recipient ID and Page Access Token
curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{"id":"1234567" }, "message":{ "text":"hello from bot" }}' "https://graph.facebook.com/v2.6/me/messages?access_token=PASTETHETOKENHERE"
This issue may also occur when you have an error in your code (syntax or logic error). In my case, I had this part in my code in webhook.php (which is my registered callback page in Facebook)
$message = $input['entry'][0]['messaging'][0]['message']['text'];
"message":{
"text":"Sorry, we currently do not have an article related to "'.$message.'"."
}
By the time I registered https://domain.com/webhook.php as callback, it wouldn't receive any $message yet so it causes an error and wouldn't accept my callback url.
Check your code and make sure you echo only the challenge.
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'verify_token') {
echo $challenge;
}
I'm trying django-tastypie with a REST client in my browser (Postman)
GET works well:
GET http://127.0.0.1:8000/api/v1/entry/
GET http://127.0.0.1:8000/api/v1/entry/1/
But I can't get PUT works with an entry:
PUT GET http://127.0.0.1:8000/api/v1/entry/1/
I get this error:
{
"error_message": "You cannot access body after reading from request's data stream",
...
}
I allowed the method in the resource though.
Where can it come from?
Thanks
OK, I have found a solution.
On postman, choose the 'raw' option and type the json data.
Then add a Content-Type header by clicking on the 'Headers' button on the top right. Type "application/json".