I am learning Symfony REST using this tutorial I found here
http://voryx.net/rest-apis-with-symfony2-the-easy-way/
I have gotten to the point where have to make a PUT using this command on my project's root console
curl -i -H "Content-Type: application/json" -X POST -d '{"name" : "Test Post", "description" : "This is a test post"}' http://localhost:8000/app_dev.php/api/posts
When I execute this command above, I get this error on my console
curl: (3) [globbing] unmatched close brace/brac
curl: (7) Failed connect to localhost:8000; No error
Please assist me I am pushing myself to learn Symfony REST
Related
I want to call my upload csv api using curl command but no able to upload file on that which gives me error.
Command I am using as follow:
curl -i -X POST -H "Content-Type:application/json" https://api.staging.mailzap.com/api/v1/api-key/upload-csv -d '{"apiKey":"Srkk8RL8xETAeJ0lTm85","email_csv":'#\"C:/Users/viral.champanery/Desktop/publicapi/test.txt\"',"team_id":282}'
following option also not working
curl -i -X POST -H "Content-Type:multipart/form-data;application/json;application/csv;" https://api.staging.mailzap.com/api/v1/api-key/upload-csv -d '{"apiKey":"Srkk8RL8xETAeJ0lTm85","email_csv":"C:/Users/viral.champanery/Desktop/publicapi/test.txt","team_id":282}'
also not working following
curl -i -X POST -H "Content-Type:multipart/form-data;application/json;application/csv;" https://api.staging.mailzap.com/api/v1/api-key/upload-csv -d '{"apiKey":"Srkk8RL8xETAeJ0lTm85","team_id":282}' -F "email_csv=#/C/Users/viral.champanery/Desktop/publicapi/test.csv"
email_csv=#/C/Users/viral.champanery/Desktop/publicapi/test.csv"
help me to upload file with json other parameter in api using curl command
AZURE - The official documentation and examples for PHP is not working, help?
I am using the code at this link:
https://github.com/courtney7/HTTP-Code-Samples/blob/37a4431f75397e1ccc6ee3f62ef14b3909a2dc85/PHP/PHPAzureToken.php
Always test and debug APIs using curl (i.e. take a curl first approach). Here's an example that works on my Windows 10 system. Here's the curl that gets a token.
curl -k --data "" "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key:<your Ocp-Apim-Subscription-Key>"
Example to get token and call text translate.
curl -k --data "" "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key:<your Ocp-Apim-Subscription-Key>" > Bearer.txt
set /p Bearer= < Bearer.txt
curl -H "Authorization: Bearer %Bearer%" "https://api.microsofttranslator.com/v2/Http.svc/Translate?Text=Hello+world.&From=en&To=es"
Make sure you are calling the correct endpoint "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"
Please find below error messages. I got those when I tried to send GCM push notifications from curl command line on my computer. What is wrong with this command?
Command Line:
curl --header "Authorization: key=AIzaSyDq5WEWwiKCcDotArJXJUY6gX2AEDcxArM" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"f_0-7BAEtbc:APA91bFjLUj6cMB6n_Vz070CeaAiIpMgP3HvaS9HeptE2SMd7HMyjCDmKpmjMpODoHdezJm62WWScYp2qIt4wfIVv1xBubdYb61jleIpLlx69X2u5j1nBiJHVc3kU8fc6VGAq_dIbBZz\"]}"
Result:
Curl failed: Couldn’t resolve host ‘android.googleapis.com”.
The best regards
Doeun KOCH
I am trying to complete a Facebook messenger bot based on this tutorial here: https://github.com/voronianski/simon-le-bottle/blob/master/GUIDE.md
As you can see in the last instruction, I must send a page access token via this cURL request in the following format:
curl -i \
-H "Content-Type: application/json" \
-X POST \
-d "{\"verifyToken\": \"YOUR VERIFY TOKEN\", \"token\": \"YOUR PAGE ACCESS TOKEN\"}" \
https://YOUR_GENERATED_URL.now.sh/token
Of course I replaced "YOUR VERIFY TOKEN" with the token I've generated and "YOUR PAGE ACCESS TOKEN" with the page access token that I've generated and "YOUR GENERATED URL" with my own url. However, I have tried multiple times and gotten various errors.
The first time I just tried copying and pasting the tokens and url into the input space and pasting the cURL request in that format. I received the following errors:
curl: (6) Could not resolve host:
-bash: -H: command not found
-bash: -X: command not found
Basically all I received were commands not found. Then, I tried a different approach and removed the new line tabs and leaving only spaces like so
curl -i \ -H "Content-Type: application/json" \ -X POST \ -d "{\"verifyToken\": \"randomverifytokenhere\", \"token\": otherrandomtokenhere\"}" https://myspecificurl.now.sh/token
Where of course I had actual working tokens and a website yet again. The commands seemed to work, but I got a whole new crop of errors like so:
curl: (6) Could not resolve host: -H
curl: (6) Could not resolve host: Content-Type
curl: (6) Could not resolve host:
curl: (6) Could not resolve host: -d
curl: (6) Could not resolve host: "verifyToken"
curl: (6) Could not resolve host: "token"
HTTP/1.1 403 Forbidden
Server: nginx
Date: Wed, 01 Jun 2016 21:51:10 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 9
Connection: keep-alive
X-Powered-By: Express
If anyone could tell me exactly how I need to format and paste it into terminal to point where it works, that would be very helpful. Or if there's an easier, better way, I would definitely appreciate that. Every other step, up until the very last instruction, has been completed. The website has already been verified with webhook by Facebook, and I only use valid tokens and the specific website generated with "NOW". Thank you very much everyone, and I appreciate the help.
Make sure you have no white space after the backslash at the end of the lines. When I highlight your command, there appears to be a space. If you remove those your problem should go away.
If you run it as a single line command, remove the backslashes that are at the end of each line.
I created a website on centos 6. I posted a request to the website (it has a php file) from a bash script with this command:
curl -X POST -d text="example" "website"
However, I can not return a response from the php file to the bash script. How can I do this?
You are making a HTTP POST request with CURL but you haven't told it to return anything.
Try this:
curl -v -X POST -d text="example" "website"
This is telling the CURL to verbosely dump everything about the response (header and body).
Here's the documentation for command line usage: http://curl.haxx.se/docs/manpage.html