rest-client

Not getting JSON response using content-type application/JSON iOS

时光怂恿深爱的人放手 提交于 2019-12-03 22:28:27
I have been provided with a REST service from my customer for which I should get JSON response for my iOS code.I am using content-type as "application/json" but somehow it is taken as "text/html" by default. I cross checked this in a REST client in my Mozilla browser using "application/json" for the content-type in header section and I could see the proper response.On using the below code, I am getting a 400 error from the server. I could always see "text/html" as being used as part of the 400 response by default NSString * strBodyOnlineStart = [NSString stringWithFormat:@"&email=***@***.com

Twitter Application Only Auth

爱⌒轻易说出口 提交于 2019-12-03 20:21:08
I'm trying to get an Application Only Auth token following the steps of this link: https://dev.twitter.com/docs/auth/application-only-auth I'm using Ruby on Rails and Rest Client to make the POST request needed and I'm setting the headers (I think) properly. The step-by-step says: URL encode the consumer key and the consumer secret according to RFC 1738. Note that at the time of writing, this will not actually change the consumer key and secret, but this step should still be performed in case the format of those values changes in the future. Concatenate the encoded consumer key, a colon

Handle Connection and Read Timeouts for RestClient calls in android

十年热恋 提交于 2019-12-03 16:26:36
I have a RestService interface with many rest calls which I am using throughout my application. I am setting timeouts for handling connection and read-timeouts ClientHttpRequestFactory httpFactory = myRestService.getRestTemplate().getRequestFactory(); if(httpFactory!=null) { if(httpFactory instanceof SimpleClientHttpRequestFactory) { ((SimpleClientHttpRequestFactory)httpFactory).setConnectTimeout(10*1000); ((SimpleClientHttpRequestFactory)httpFactory).setReadTimeout(30*1000); } else if(httpFactory instanceof HttpComponentsClientHttpRequestFactory) { ((HttpComponentsClientHttpRequestFactory

How to send a post request to the RESTserver api in php-Codeigniter?

空扰寡人 提交于 2019-12-03 13:31:32
I've been trying to make a POST request in my CodeIgniter RestClient controller to insert data in my RestServer, but seems like my POST request is wrong. Here is my RestClient POST request in controller: $method = 'post'; $params = array('patient_id' => '1', 'department_name' => 'a', 'patient_type' => 'b'); $uri = 'patient/visit'; $this->rest->format('application/json'); $result = $this->rest->{$method}($uri, $params); This is my RestServer's controller: patient function visit_post() { $insertdata=array('patient_id' => $this->post('patient_id'), 'department_name' => $this->post('department

Ruby rest-client file upload as multipart form data with basic authenticaion

跟風遠走 提交于 2019-12-03 12:12:59
问题 I understand how to make an http request using basic authentication with Ruby's rest-client response = RestClient::Request.new(:method => :get, :url => @base_url + path, :user => @sid, :password => @token).execute and how to post a file as multipart form data RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb') but I can't seem to figure out how to combine the two in order to post a file to a server which requires basic authentication. Does anyone know what is the best way

How to debug/display request sent using RestClient

非 Y 不嫁゛ 提交于 2019-12-03 11:32:58
问题 I am trying to use RestClient to access a webservice using post method. I am sending the authorization token as specified but I am still getting a 403 status error which means I am forbidden to use that api. Is there any way that I can see the request being sent with http post so that I can verify the headers? I am not able to find any example or any documentation which mentions as to how to do that? My code is similar to this : token = get_token response = RestClient.post "https://api-dev

How to upload a file using a rest client for node

余生长醉 提交于 2019-12-03 11:09:09
问题 I have a REST client on node, and I'm trying to upload pdf a file to another REST webserver which provides the ability to parse my pdf and extract some data. Basically it is a service. The npm package that I use is: https://www.npmjs.com/package/node-rest-client. If there are other rest clients, I can use those as well. The rest api I need to use is described below: POST / ; Uploads a new PDF document via a form <br> POST /file ; Uploads a new PDF document via bytestream The question is how

ruby rest-client: make it never timeout?

两盒软妹~` 提交于 2019-12-03 10:57:40
I am trying to use ruby rest-client to upload a large number of images to a site that I'm writing. My code looks like: RestClient.post url, :timeout => 90000000, :open_timeout => 90000000, :file_param => file_obj However, I am getting this error: RestClient::RequestTimeout: Request Timeout from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.1/lib/restclient/request.rb:174:in `transmit' from /Library/Ruby/ But when I look at the server log Completed in 61493ms (View: 2, DB: 1) | 201 Created So there doesn't appear to be any reason why this is timing out. Anyone have any idea if there is a timeout

Can I override RESTClient default “HttpResponseException” response to >399 Return Codes?

廉价感情. 提交于 2019-12-03 10:53:44
I'm using the Groovy RESTClient class to do write some (spock) Acceptance tests for Java WebServices I've been authoring. One frustration I've had is in testing the responses... 200 Status's are easy: when: def result = callServiceWithValidParams() then: result.status == 200 But with 400+ I'm forced to either wrap in a try-catch , or test for the HttpResponseException that RESTClient throws by default. when: callWithInvalidParams() then: def e = thrown(Exception) e.message == 'Bad Request' This is sort-of OK, if a little frustrating... but I want to do better. Ideally, I want my tests to more

Tool for testing RESTful Web services [closed]

独自空忆成欢 提交于 2019-12-03 08:48:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am trying to evaluate the right tool to test RESTful Web services and eventually automate the same for our project. Wondering, what are the specifications I need to look for such test, when i compare various tools on internet. Definitely, one of the requirements would be an Open source tool. I have looked on