Hi I'm very new to Grails. I have set of api's that I wish to test. By using curl command I can test those api's like this:
curl --verbose https://x.x.x.in/init_order -u x-x-x-x-x-x-x-B4E4E: -d "amount=400.00" -d "order_id=xxxxxx" -d "customer_id=xxxxx101" -d "customer_email=customer#mail.com"
This will give a response in JSON.
What I want is I need to hit this url. I thought ? is the separtor in params of grails. But when I do something like this:
https://x.x.x.in/init_order/x.x.x.x.x?no=123?no2=234
and print the params, I can see I get no as 123?no2=234. Here the ? is not separating my params.
Very new to Grails, I wonder where I'm making the mistake.
Thanks in advance.
It's not grails specific. In HTTP you use ? to start the parameter list then & to separate the parameters from each other.
The default URL Mapping is /$controller/$action?/$id?
So if you had BookController with an action of findBooks and wanted to pass in parameters author and title it would look like:
http://yourdomain.com/book/findBooks?author=Grisham&title=Firm
Related
This suggests it does :
https://youtube-eng.googleblog.com/2009/10/oembed-support_9.html
But I'm getting nothing back when I do, say
curl "https://www.youtube.com/oembed" -d 'format=json' -d 'url=https://www.youtube.com/watch?v=uXBDgLglFig'
Does anyone know if the oembed API has been deprecated?
You're making a POST request with those options you're passing to curl. You need to make a GET request instead, like so:
curl 'https://www.youtube.com/oembed?format=json&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DuXBDgLglFig'
Note that the URL parameter must be URL encoded. How you do that depends on what language you're using to make the request.
I see a lot of useful methods in the API, but I don't find any method to list all my Posts, or all the posts from within a publication. Is this intentional?
Thought it would be something really obvious to exist in the API. Or am I missing something?
Got it, just use the RSS feed instead.
I wrapped a Github package by #mark-fasel into a Clay microservice that enables you to do exactly this:
Simplified Return Format:
https://clay.run/services/nicoslepicos/medium-get-users-posts-simple
What Medium actually returns at the endpoint
https://clay.run/services/nicoslepicos/medium-get-users-posts
I put together a little fiddle, since a user was asking how to use the endpoint in HTML to get the titles for their last 3 points:
https://jsfiddle.net/h405m3ma/1/
You can call the API as:
curl -i -H "Content-Type: application/json" -X POST -d '{"username":"nicolaerusan"}' https://clay.run/services/nicoslepicos/medium-get-users-posts-simple
You can also use it easily in your node code using the clay-client npm package and just write:
Clay.run('nicoslepicos/medium-get-users-posts-simple', {"username":"usernameValue"}) .then((result) => {
// Do what you want with returned result console.log(result);
})
If you need to generally pull down an RSS feed, here's a microservice for that:
https://clay.run/services/nicoslepicos/rss-to-json
So I just understood that the Slack Web API does not support JSON data over POST. Which means I have to encode my complex and nested JSON object to fit in query parameters over GET. Problem is, the attachements don't seem to work. Does anyone have a solution ?
So I just understood that the Slack Web API does not support JSON data over POST. Which means I have to encode my complex and nested JSON object to fit in query parameters over GET.
I'm not sure I follow what you mean. You can certainly use POST. The body of a Slack API call should be form-encoded, but parameter values are sometimes JSON (as is the case for attachments).
Here's a working curl command that uses HTTP POST to post a message with a simple attachment.
$ curl -d token=<REDACTED> -d channel=<REDACTED> \
-d text="This is the main text." \
-d attachments='[{"text": "This is an attachment."}]' \
https://slack.com/api/chat.postMessage
I'd recommend using POST, but GET also works fine. If you fill in the values in https://api.slack.com/methods/chat.postMessage/test, the tool will give you a URL at the bottom that you can use with HTTP GET.
i have ruby on rails based api which accepts a get request.
example :
http://localhost:3000/api/search?query=whatis&access_token=324nbkjh3g32423
when i do curl from mac terminal like
curl http://localhost:3000/api/search?query=whatis&access_token=324nbkjh3g32423
i checked in the server with "request.fullpath", it return only "/api/search?query=whatis", the second parameter is missing.
however if i do curl like
curl --data="query=whatis&access_token=324nbkjh3g32423" http://localhost:3000/api/search
it is taking all the parameters.
i understand there is a problem with encoding, but i what to know what difference is there with the two requests.
Thanks in advance
The problem probably is that bash shell sees & as the end of the command.
try quoting the entire querystring like this -
curl "http://localhost:3000/api/search?query=whatis&access_token=324nbkjh3g32423"
I am trying to
1) post some XML to my Rails App (without using forms)
2) have my Rails App then parse the posted XML to create entries within my database
For example, I'd like to post
<transaction>
<date>12-01-2010</date>
<amount>1.00</amount>
</transaction>
<transaction>
<date>12-02-2010</date>
<amount>2.00</amount>
</transaction>
Assuming I have a transaction controller. I'd then like to create an "upload" action that would allow me to parse the snippet above and create entries within my database.
From my research it seems like 1) can be accomplished with curl. But I'm not sure if that is right, because I don't know what URI to point the curl command to.
I am also not clear how to get the XML data within the "upload" action of my controller.
Any help would be appreciated.
Thank you!
You have to set Header Content-type, send as POST request and then you have only worry about the XML posted content
Here is a example of how to post xml by using curl
curl -X POST -H "Content-Type:text/xml" -d "<xml>Your XML Data</xml>" "http://your url"
XML parameter parser is removed in Rails 4, so if you're using Rails 4, you need to install actionpack-xml-parser gem first, refer to https://github.com/rails/actionpack-xml_parser