Change the request_method from GET to POST - apache

I need to transform a HTTP Request from a GET method to a POST methode in Apache.
Is it possible ?
I'm working with Dailymotion. This service send a GET method to my REST API to post some data. But I would like to receive a POST method to respect REST protocol.
I'm trying to make this transformation with Apache.
Thanks a lot.

Related

JMeter: Record n play, also gives API access

I have recorded a login flow of an application and found some URIs like below:
/api/oauth2/initiate GET
/oauth2/authorize GET
/api/v1/oauth2/authorize GET
/api/v1/oauth2/authenticate POST
{"username":"${Username}","password":"${Password}","client_id":"${client_Id}","response_type":"code","redirect_uri":"${scheme}://${host}/api/oauth2/callback","server_id":"${server_Id}"}
When I am hitting above in sequence via JMeter I am getting 200 response. Just like JMeter I tried recording in Postman and it worked same, but instead of JSON it gave response in XML format.
It doesn't generate a access_token, it works via session cookies.
My question is - Do I really have API access or it is just browser record n play? If Yes, Does this mean I can get access to any API, if I am a registered user of that application? For ex: Facebook, YouTube or any startup website.
JMeter works on the protocol level. This means that whatever request you are generating. Say a simple browser request or an API call, you can do that easily.
Now the thing is replicating requests. You don't need to record the requests necessarily using the browser. You need to analyze the few things that are required. Say Postman is generating a request. You specify the things you want to send and you use the API Token there. The same things can be specified there as well. It all depends on how you are understanding the concept of request generation.
You simply need to replicate the samplers and the parameters. And the request headers in postman can be replicated here in the same way.
For each HTTP Request Sampler make sure you add a corresponding child HTTP Header Manager config element.
Headers basically tell the server that what client we are using and in what form data is being sent and then server responds accordingly with the information.
What you're recorded is OAuth2 flow and you won't be able to replay it without correlating the dynamic values.
You can have access to Google API or Facebook Graph API given you have proper access_token but I don't think you should be testing them directly, you should focus on solely your application.

Wirecloud / Fi-Ware edit request header in http.makerequest method

I’m working on an widget for the fiware mashup. It needs to get data in json from a server. I’ve realized that with the MashupPlatform.http.makeRequest.
The problem is, the server sends xml back, if I don’t ask to get json. I don’t find any option in the widget api to to do it so. (like the curl option --header 'Accept: application/json')
As you have said, when you perform an HTTP request, you should add the Accept header to specify the response format. When you are using the MashUp Platform to make requests, you can specify the headers by adding the object "requestHeaders" in the options parameter. For example:
MashupPlatform.http.makeRequest("http://YOUR_SERVICE_URL/PATH", { "requestHeaders": {"Accept":"application/json"}});
You can check all the options that you can include in a HTTP request in the documentation: https://wirecloud.readthedocs.org/en/latest/widgetapi/widgetapi/#request-options-general-options
Best Regards

Instagram API Returning Invalid Format for Callback_Url Error

I'm using the Instagram API.
I'm trying a simple post for a subscription request, and I keep getting
"Invalid format for 'callback_url'. URL must start with http:// or
https://".
It clearly starts with that.
I can't find anyone online that's running into this same problem.
Tried the post with a clear callback url:
http://api.instagram.com/v1/subscriptions/?client_id={client_id}&client_secret={secret}&object=tag&aspect=media&object_id=skateboarding&callback_url=http://skateparkoftampa.com/spot/instagram_callback.aspx
And with an HTML encoded callback URL:
http://api.instagram.com/v1/subscriptions/?client_id={client_id}&client_secret={secret}&object=tag&aspect=media&object_id=skateboarding&callback_url=http%3A%2F%2Fskateparkoftampa.com%2Fspot%2Finstagram_callback.aspx
Also tried it with both GET and POST, also by letting the API console create the request by simply filling in the parameters fields, etc. I feel like I'm missing something really obvious or something, but I'm stuck. Any ideas?
As sais on Endpoints page:
All endpoints are only accessible via https
You should use your own CLIENT-ID and SECRET-ID and callback url (so don't use API console).
Your callback url may be without https.
Just use link with https:
https://api.instagram.com/v1/subscriptions/
Try examples from this page
You should use POST request to subscribe and unsubscribe, and GET to get list of subscriptions. Please, read documentation accurately.

How to call PUT method in Fiddler

I created a PUT WCF service to update my database. How do I call this service in fiddler to test if it working properly.
I did try the URL in Fiddler and it gave me 404!
Anyone help me with this?
In the request builder there is a drop down. By default it shows "GET" and it allows you to select the HTTP method that you wish to use. Change this to "PUT" and you should be done.
You might also want to take a look at this...
Doing a HTTP PUT from a browser
... and investigate the use of the X-HTTP-Method-Override header.
You should also read this...
Use Fiddler to Test RESTful WCF Services
http://www.keyvan.ms/use-fiddler-to-test-restful-wcf-services

Access to request HTTP headers in custom WCF MessageEncoder

Does anyone know how to get access to request HTTP headers within MessageEncoder.ReadMessage method?
It seems that WCF already "knows" request headers at the point of invoking ReadMessage method, at least Content-Type and Content-Length but I cannot get the access to the Content-Encoding header.
Basically, I'm trying to utilize gzip de/compression for WCF service (http://msdn.microsoft.com/en-us/library/ms751458.aspx) and would like to check if decompression is necessary for incoming request. To do that I'd like to check Content-Encoding header but cannot figure out where to get it.
Any ideas?
Thanks!
Here's an answer I gave in another thread which explains how you would need to manipulate the headers via the WebOperationContext in another IOperationBehavior which is coupled with the MessageEncoder.