Put method cant receive body data but work with direct URL pass parameter - rest

i call api using postman ... api work fine with if i choose put method and pass a url like:
https://URL/user/123?id=123&name=foo
but if i using this link :
https://URL/user/123
And pass data in body put method not working.
I try to use form-data and x-www-form-urlencoder .. all not working .
Anyone know what is my problem ..
thank for your help.
and sorry for my bad English

Try to use RAW format with particular data-type/content-Type which your using in web service Eg: JSON(application/json) Hope this will solve your problem

Related

How to extract part of RAW response body (not JSON!) in INSOMNIA Rest Client

I am using the Insomnia REST client to debug some mobile API. I need to extract part of one value in the response body and put it into a second request.
Request
The request is an Oauth request for an authorization token. This request is normally sent from a mobile app.
Example Response
The backend responds with a redirect_uri that contains the authorization_code. This format is used in oauth when the request (normally in PROD) comes from a mobile app.
{
"redirect_to": "redirect_uri=com.acme://oauth?client_id=abcde&response_type=code&scope=authenticate_user&authorization=H068bFHTXXXXXXXXXXX.....XXXXXXX"
}
How can I extract the value of the authorization parameter from this response in INSOMNIA?
** How can I extract only the part after "&authorization=....."**
I know how to extract the full value of the "redirect_to" JSON attribute. But then how to parse it? For example with a regex?
it is possible to do so, but it is kind of tricky. The most obvious way would be to use some plugin, but here is what I came up with:
Firt of all you need to make a variable which will save your response redirect_uri=com.acme ... =authenticate_user&authorization=H068bFHTXXXXXXXXXXX.....XXXXXXX.
You can do this by pressing:
CTRL + E
This will open your environment variables, you can really make it in any enviroment, but probably the best would be to do in Base Enviroment so it is accessable no matter which environment you are using.
Create a variable like this:
placeholder variable
Then you need to get the redirect_uri by pressing the following keys between the quotation marks:
CTRL+SPACE
This will bring up the quick menu, where you can type Response and choose body attribute. Click on it, and set it like this.
I am pretty sure most people are familiar till this point.
Now you have saved the response to a variable you can use it. Navigate to the request where you want to use it, and you can type (basically in any field) {{ }}.
Inside this variable write the following (with your own variable name).
{{ redirect_uri.match('authorization=([^&]+)')[1] }}
This is basically javascript, using a simple regex to match the url parameter.
If you did everything correctly you will see something like this, and by clicking on it you should see your token.
Note: It might be red, until you get some values into the variable that you made.
I really hope it helps.

adding url with parameters to tweetinvi

I am trying to publish a tweet that includes a url that ends like
?r=twitter&lkey=oxvN3E8o3 and it does not work. Tweeter returns {"errors":[{"code":32,"message":"Could not authenticate you."}]}. but if I remove parameters it works. BTW length is not a problem.
Thanks
I have been check out to your link that is work correctly . Again you try it but you do not enter hello befor link . Only you enter link in publish function.

Unknown number of Parameters in GET request: Play Framework 2.3.x+ Twilio

I am trying to point my twilio voice URl to my server.
So my routes files has this line:
GET /v1/twilio/ controllers.Application.call()
When I get the request from Twili, I get it as below:
/v1/twilio/?AccountSid=someRandomSID&
ToZip=0000&
FromState=A&
Called=%2B109213098234&
FromCountry=US&
CallerCountry=US&
CalledZip=9000&
Direction=inbound&
FromCity=xyz&
CalledCountry=US&
CallerState=A&
CallSid=randomSID&
CalledState=A&
From=%2B123455667&
CallerZip=90909&
FromZip=9890&
CallStatus=ringing&
ToCity=BLA&
ToState=AA&
To=%2B765213765&
ToCountry=PQR&
CallerCity=PT&
ApiVersion=2010-04-01&
Caller=%23123213&
CalledCity=BB]
SO you see, there are a lot of parameters.
My problem is that I am Not aware of all the parameters.
So when I just put above line in my routes file, I get an Error: 404 Not found.
How should modify the routes file so that I get the GET request?
If I ask twilio to send me POST request, then I don't have to worry about it as then I can simply get the parameter I need by Querying thee RequestData.
But there has to be some way I can get GET REQUEST to succed and reach my application controller.
Please help me here.
sorry if this is a silly question. But I am really struggling to get some info.
PS: I am using 2.3X version of play framework
Also, I dont have the control over parameters sent by Twilio.
I will simply get a GET/POst request, as per this : https://www.twilio.com/docs/api/twiml/twilio_request#synchronous
There's nothing unusual with this route, it works with sample URL like a charm (checked) maybe Twilio untrails return path by default? try to add spare route for handling this case as well:
GET /v1/twilio controllers.Application.call()
GET /v1/twilio/ controllers.Application.call()

POST request from iPhone to Django

I'm trying to send a POST request from iPhone to Django, but for some reason I can't. The request is sent, but the server doesn't receive it properly.
What is the regular expression that accepts POST? In my case, I use this one: /messages/a/s=person1&r=person2&c=hello/.
How do I retrieve the POST arguments in the Django view? request.POST['s'] should work?
Thanks.
POST parameters are not part of the URL, so your regex should simply detail the main part of the url you want to receive it on. To take your example, change it to /messages/a/. Then, in your "messages" app, have a view/function called a: that one will be reached on receiving any POST (or GET, which you're currently (almost) depicting in your url) to that location.
The arguments can then indeed be retrieved using request.POST['keyname']. To make things more convenient, supply a default value when getting the data so you need less error checking: request.POST.get('keyname', None). This will get the value of keyname when available, or None otherwise.
The posting itself... depends on more code then you're currently showing. Can't say anything about that with your current question.
That URL you've pasted in will pass the data through the request.GET dictionary. If you want to change your iPhone app to POST data, you'll have to share your code.

How can i call a receive activity from a xamlx workflow service using javascript?

I need to call a receive activity in my workflow from javascript passing the parameters as json and i need the response as json format too..
I tried everything that i found but nothing works.
Hope you can help me... thanks
The Receive activity only supports SOAP requests and at the moment there is no way to do REST style communications with it. One work around would be to create a regular WCF REST service as a wrapper for your workflow and have the JavaScript client go through this wrapper.
Thank you very much for your answer. I will do it, i found this page "http://msmvps.com/blogs/theproblemsolver/" and now i know how keep the receive activities because i was not clear if i should remove them from my workflow or keep it... Here is a litle piece of code that show how to.
var factory = new ChannelFactory(new BasicHttpBinding(),
new EndpointAddress("http://localhost:9199/Service1.xamlx"));
var proxy = factory.CreateChannel();
var response = proxy.GetData(new GetDataRequest() { Value = 42 });
Console.WriteLine(response.Value);