rest-client

Getting ssl.SSLHandshakeException when using REST client with header but works fine with PostMan

雨燕双飞 提交于 2019-12-29 07:13:33
问题 I have an external REST resource with below details: The URL: abc.com/orders (the domain is with https ) I need to pass UserID as an HTTP header with key "user" value is "abcd" This would return an JSON response I am using below Java code for this: try { Client client = Client.create(); WebResource webResource = client.resource("abc.com/orders"); ClientResponse response = webResource.header("user", "abcd").accept("application/json") .get(ClientResponse.class); if (response.getStatus() != 200)

ErrorInvalidRequest while using post request in office365

坚强是说给别人听的谎言 提交于 2019-12-25 04:50:09
问题 using restClient, I am trying to add a new event. url: https://outlook.office365.com/ews/odata/Me/Events My json for the creation of an event is {"IsAllDay":false,"Subject":"TEST","Start":"2015-02-20T07:32:39Z","End":"2015-02-20T08:32:39Z","Body":{"ContentType":"HTML","Content":"TEST JRA ? TU VOIS ?"}} The response I get is { "error": { "code": "ErrorInvalidRequest", "message": "Cannot read the request body." } } What is wrong with my json and how do I solve this error ? 回答1: Make sure your

How do I use rest-client for ruby to post an image?

。_饼干妹妹 提交于 2019-12-25 04:13:58
问题 I am trying to find a way to use the Postful API and I need to post an image in the body of the request. I am trying to use rest-client (but am open to other ways): The error I get when I post is HTTP status code 422 Basically, I'm clueless and need guidance. :\ class PostfulsController < ApplicationController require 'rest_client' def submit body = "<?xml version='1.0' encoding='UTF-8'?> <mail> <documents> <document> <template> <source>gallery</source> <name>Postcard: Image fit front</name>

How do I use rest-client for ruby to post an image?

陌路散爱 提交于 2019-12-25 04:13:02
问题 I am trying to find a way to use the Postful API and I need to post an image in the body of the request. I am trying to use rest-client (but am open to other ways): The error I get when I post is HTTP status code 422 Basically, I'm clueless and need guidance. :\ class PostfulsController < ApplicationController require 'rest_client' def submit body = "<?xml version='1.0' encoding='UTF-8'?> <mail> <documents> <document> <template> <source>gallery</source> <name>Postcard: Image fit front</name>

Elasticsearch Rest Client throws java.lang.ArrayStoreException

橙三吉。 提交于 2019-12-25 03:12:03
问题 I am using Elasticsearch Rest Client v5.5.3 to execute Elasticsearch queries in a Java application. It always throws java.lang.ArrayStoreException. First I suspect frequency of query execution since application intensively executes queries but it throws exception very first query. Second I update some dependencies like Apache HttpCore.jar which Elasticsearch rest client uses. But either way I could not figure out how to solve it still throws exception. Stack trace is below; java.lang

make a request using REST_CLIENT, equivalent to a curl request

冷暖自知 提交于 2019-12-25 01:58:02
问题 I am trying to make this curl request using rest_client, and I keep getting it wrong. How can I do it? curl request: it is working well and returning an access token from yahoo. curl -u "<consumer_key>:<consumer_secret>" -d "grant_type=authorization_code&code=<code>&redirect_uri=<redirect_uri>" https://api.login.yahoo.com/oauth2/get_token the rest_client request that I am trying to make work is: # get token yahoo_url = "https://api.login.yahoo.com/oauth2/get_token/" response = RestClient:

MicroProfile Rest Client not working

淺唱寂寞╮ 提交于 2019-12-25 01:37:23
问题 I had created a demo application using Wildfly Swarm generator, and I want to add the MicroProfile Rest Client on it. I just added the dependency: <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>microprofile-restclient</artifactId> </dependency> And call the RestClient instantiation code: UserService userService = RestClientBuilder.newBuilder().baseUrl(apiUri) .build(UserService.class); Even if I do not add the lines above, only the dependency, my application presents a

Ruby Oauth Gem HMAC-SHA1 401 Invalid Signature

孤者浪人 提交于 2019-12-24 06:06:03
问题 I'm using rest-client with oauth, the oauth headers are getting generated, but the hmac-sha1 signature is invalid. The server doesn't accept signature encoding, returns 401 oauth_problem signature_invalid. oauth_signature="9aOk2oM2%2FczpqHBJ95MhcF%2Bp6XU%3D", oauth_signature_method="HMAC-SHA1" Running in Postman with "Encode OAuth signature" un-selected works fine. Postman gives same 401 invalid signature when this option is turned on. Is this encoding the problem, is there a similar option

Twitter Application Only Auth

被刻印的时光 ゝ 提交于 2019-12-21 05:37:14
问题 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

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

人走茶凉 提交于 2019-12-21 03:37:50
问题 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'