Giter Club home page Giter Club logo

hipchat-api's People

Contributors

catac avatar itsmefox avatar nik-sta avatar nikolastankovic avatar paulpearcy avatar viascom-account avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hipchat-api's Issues

Bug with recent room messages

I'm trying to cut down the message collection by "not-before" some ID and a max-results of 15. Somehow I always get the default 75 items and the "not-before" is ignored as well.

ViewRecentRoomHistory history = new ViewRecentRoomHistory();
history.setMax_results(15);
history.setNot_before(latestRoomIds.get(room));
ViewRecentRoomHistoryResponse rep = hipChat.roomsApi().viewRecentRoomHistory(room, history);

When I debugged your code it looks like the final request is this:

https://api.hipchat.com/v2/room/MyRoom/history/latest?timezone=UTC&not_before=5110cadc-056f-4e92-860a-ff8f75cf905f&max_results=15&include_deleted=true

However, the documentation says that those parameters should have dashes and not underscores.
"not-before" vs. "not_before"
Docs: https://www.hipchat.com/docs/apiv2/method/view_recent_room_history

Maybe something is ignoring your annotations?

Cheers,
Bjoern

Question?

Didn't find other way to contact authors so ask here:

Is this hipchat-apii suitable for bots that stays online in chat room?

Like when starting, bot joins configured rooms and handles commands via
messages from room..

Release 2.0.3?

First of all thank you for all the work you've done here.

Is there any change to release 2.0.3 version? I'm specially interested in the fix applied in #18

Thanks in advance,
Rafa.

Unable to use non-ASCII characters in sendRoomMessage()

Hello,

I tried integrating hipchat-api to send messages to a specific Hipchat room on an Hipchat cloud account and I ran across a funny issue:

  • Sending simple messages like Hello world! works fine.
  • Sending a message containing a character not from the ASCII charset (like Hello é world!) fails with a 400 error from Hipchat server, letting me know it failed to parse the request body as UTF-8.

Here's the response from the Hipchat server:

FoxHttpResponse(responseBody=FoxHttpResponseBody(body={
  "error": {
    "code": 400,
    "message": "The request body cannot be decoded as UTF-8: 'utf8' codec can't decode byte 0xe9 in position 90: invalid continuation byte",
    "type": "Bad Request"
  }
}), responseCode=400, responseHeaders=FoxHttpHeader(headerEntries=[HeaderEntry(name=X-Ratelimit-Reset, value=1514665166), HeaderEntry(name=X-Ratelimit-Limit, value=100), HeaderEntry(name=Access-Control-Expose-Headers, value=Date, ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-Backoff), HeaderEntry(name=Server, value=nginx), HeaderEntry(name=X-Ratelimit-Remaining, value=98), HeaderEntry(name=Access-Control-Allow-Origin, value=*), HeaderEntry(name=Connection, value=keep-alive), HeaderEntry(name=Content-Length, value=204), HeaderEntry(name=Date, value=Sat, 30 Dec 2017 20:15:56 GMT), HeaderEntry(name=Content-Type, value=application/json)]), foxHttpClient=ch.viascom.groundwork.foxhttp.FoxHttpClient@45da906e, foxHttpRequest=ch.viascom.groundwork.foxhttp.FoxHttpRequest@3b6031c2)

If I look at the raw request using Wireshark, I notice that the é character is encoded as 0xe9 (latin-1) instead of being encoded as 0xc3 0xa9 (UTF-8). Since the content-type of the request is set to application/json; charset=UTF-8, it's understandable for the Hipchat server to get confused.

I can reproduce the issue with the following snippet (I opened a web server on port 8080):

FoxHttpClient client = new FoxHttpClientBuilder(new GsonParser()).build();

client.setFoxHttpLogger(new SystemOutFoxHttpLogger(true, "FoxHttp-Logger"));

String[] bodies = {"Hello world!", "Hello é world!"};

String url = "http://localhost:8080/test";

for (String body : bodies) {
    FoxHttpRequestBuilder requestBuilder = new FoxHttpRequestBuilder(url, RequestType.POST, client);
    MessageRequestBody messageRequestBody = new MessageRequestBody(body);
    requestBuilder.setRequestBody(new RequestObjectBody(messageRequestBody, ContentType.APPLICATION_JSON));
    requestBuilder.build().execute();
}

Here are the raw data extracted via Wireshark:

Hello world!

0000   7b 22 6d 65 73 73 61 67 65 22 3a 22 48 65 6c 6c  {"message":"Hell
0010   6f 20 77 6f 72 6c 64 21 22 7d                    o world!"}

Hello é world!

0000   7b 22 6d 65 73 73 61 67 65 22 3a 22 48 65 6c 6c  {"message":"Hell
0010   6f 20 e9 20 77 6f 72 6c 64 21 22 7d              o . world!"}

(see how é got encoded as 0xe9).

Is this a limitation of FoxHttp or am I doing something wrong?

Issue when posting using email with a dot

Hello,

When posting a private message like:

HipChat hipchat = new HipChat(accessToken);
PrivateMessage p = new PrivateMessage();
p.setNotify(true);
p.setMessage_format(MessageFormat.TEXT);
p.setMessage("Hello world");
p.setUserId(email);
hipChat.usersAPI().sendPrivateMessage(p);

This works all fine if the email address looks like [email protected].

But when the email address has a dot, such as [email protected], got an exception:
Response-Statuscode: 400
In the exception, one can read The request JSON can not be parsed as valid JSON: Expecting property enclosed in double quotes.

Deeper debugging shows the body sent to the hipchat server looks like: { [email protected]", "message":"Hello world","notify":"true","message_format":"text"}, what is obviously not a valid JSON.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.