viascom / hipchat-api Goto Github PK
View Code? Open in Web Editor NEWJava implementation for the HipChat V2 API.
License: Apache License 2.0
Java implementation for the HipChat V2 API.
License: Apache License 2.0
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¬_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
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..
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.
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:
Hello world!
works fine.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?
Currently, it is only possible to update the presence of a user via:
HipChat hipChat = ...
hipChat.usersApi().(someEmail, new UpdateUser(newPresence));
It would be nice to be able to update more properties as documented here:
https://www.hipchat.com/docs/apiv2/method/update_user
I'm willing to create a PR for this.
Not really shocking:
public class MessageMention {
}
I may add support for this sooner or later and wanted to get notified if this got fixed.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.