Restler3: DELETE Body JSON - php

I really don't understand what I should do to make a DELETE request.
I want to use JSON as in/output only, so also a DELETE request should receive JSON.
But that doesn't make the goal:
public function delete($request_data = NULL)
$request_data is nil every time. I'm trying it by using cURL:
curl -X DELETE http://…/API/index.php/test.json -H "Content-Type: application/json" -d '{"key":"test","value":"1337"}'
Can someone explain that to me?

Related

How to Post data from external HTML form to Eloqua Form using cURL

I want to post data from an external HTML form to a simple form created in Eloqua, using cURL method. I tried to follow this documentation but I am not able to post data to Eloqua.
When I try from command line (Windows) -
curl --user "usercreds" --header "Content-Type: application/json" --request POST --data "{"testfirstname":"abc","testlastname":"def","singleCheckbox":1}" https://secure.p0{POD Number}.eloqua.com/api/REST/1.0/data/form/{formid}
I get below error:
[{"type":"ObjectValidationError","property":"fieldValues","requirement":{"type":"NoDuplicatesRequirement"},"value":""}]
When I try from PHP, as mentioned here https://www.eehelp.com/question/using-curl-to-repost-to-eloqua-data/
or https://github.com/fredsakr/eloqua-php-request the curl returns HTTP code 0.
This is a simple form created in Eloqua without any validations.
I do not know what I am doing wrong here.

Curl request not working using php script

I have curl using voxbone API action method pass "did_dropdown" parameter value to get country wise dids. But another thing I am passing action method "didlist_type_city" parameter value not any response with pass country.
Note : Get url is working on terminal command line but postman api not any response get
curl -u xxxxx:xxxxx -H "Content-type: application/json" -H "Accept: application/json" "https://sandbox.voxbone.com/ws-voxbone/services/rest/inventory/did?didIds='xxxxxx'&pageNumber=0&pageSize=1&countryCodeA3=IND"

Facebook graph API: mark message as read

I get message conversations via Facebook graph API which looks like:
https://graph.facebook.com/' + id + '/messages?fields=message
and I want to mark as read the message but I can't find how to in documents.
please, can someone point me to some examples?
You only have read access to the Inbox via the API. So this is not currently possible.
You can set typing indicators or send read receipts using the API, to let users know you are processing their request.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"<PSID>"
},
"sender_action":"typing_on"
}' "https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>"
Check below.
sender action = mark_seen..
I am using it and its working fine..
https://developers.facebook.com/docs/messenger-platform/send-messages/sender-actions/
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"<PSID>"
},
"sender_action":"mark_seen"
}' "https://graph.facebook.com/v2.6/me/messages?access_token=
<PAGE_ACCESS_TOKEN>"

Post json data stored in variable using curl

Sending POST request data stored in a variable using curl, sends $variable instead json data.
P=`/usr/bin/sudo /usr/bin/curl -X POST -H "Content-Type:application/json" --data-urlencode $data http://127.0.0.1/abc.php`
Trying to send POST request to php, but it receives $data instead json data{"abc":"11","xyz":"20"}.
Had try with '$data', "$data", \'$data\' and \"$data\", where $data = {"abc":"11","xyz":"20"}
Please give an example that works. Thanks in advance.
P=`/usr/bin/sudo /usr/bin/curl -X POST -H "Content-Type:application/json" -d "$O" http://127.0.0.1/abc.php` solves issue.
If you add single quote it won't expand variable, so it requires to add double quote.
I suggest all time reload page or script, as I have seen if you not reload, it work with your last change instead new one.

POST json returns 400 with curl but functional test working

I am trying to build the POST of an API using Symfony2 and FOSRestBundle. The following functional test returns OK.
public function testPostArticleAction(){
$this->client->request(
'POST',
'/api/v1/articles.json',
array(),
array(),
array('CONTENT_TYPE' => 'application/json'),
'{"articleContent":"The content of the content"}'
);
$response = $this->client->getResponse();
$this->assertJsonResponse($response,201, false);
}
But when I try to send a request via Curl with the same request body, it gives me a 400 invalid json message:
{"code":400,"message":"Invalid json message received"}
Here are the curl commands I have tried:
curl -X POST -d '{"articleContent":"title1"}'
http://localhost:8000/api/v1/articles --header
"Content-type:application/json"
curl -X POST -d '{"articleContent":"title1"}'
http://localhost:8000/api/v1/articles.json
Please to note that the GET returns to me a json like:
{"id":68,"article_content":"contents contents"}
But my field is articleContent in my doctrine mapping file. What am I missing?
Your help is much appreciated.
Try updating your header option to:
"Content-Type: application/json"
Additionally - does this request require any type of authentication? You'd need to pass in an auth cookie if so.

Categories