Giter VIP home page Giter VIP logo

hipchat-cs's Introduction

Note The company I work for no longer uses HipChat so maintaining this is much harder. If anyone is interested in taking this over and handling checking out the pull requests or fixing issues drop me a line and I'll hand over the reigns. I won't be making anymore updates here.

Hipchat-CS

An easy to use C# wrapper on the V2 Hipchat API

Can be installed through nuget.

Install-Package Hipchat-CS

Not all methods are added yet, but if you find something you need, feel free to create a pull request, or request support for it in the issues.

Getting Started

Before you can use any of the methods you need an API key, or an auth token.

The easiest method is to login to hipchat, click on Account Settings, click on API Access and you should see your personal bearer token there

Auth pic

Using this method will access the api as yourself (all notifications/messages sent will be from you).

Once you have your api key, you can easily use the api

var client = new HipchatClient(apiKey);

//assume we have a room named 'My Room'
client.SendNotification("My Room", "This is your captain speaking");

All methods have several optional paramaters and or overloads, fully documented. Check intellisense.

Examples

//will look for an environment variable named 'hipchat_auth_token',
//or you can pass it in via the constructor
var client = new HipchatClient();

//check source or intellisense for overloads
//create a default room with whoever the api key holder is as owner
HipchatCreateRoomResponse testRoom = client.CreateRoom("My Test Room");

//send a message to the created room with the green background color
client.SendNotification(testRoom.Id, "Hello from Api!", RoomColors.Green);

//delete the room, kicking everyone out
client.DeleteRoom(testRoom.Id);

For more examples check the IntegrationTests project files

hipchat-cs's People

Contributors

agc93 avatar bartmcv avatar cesardv avatar frankneumann avatar gobelk avatar ilushka85 avatar jessebarocio avatar kantis avatar kylegobel avatar maralm avatar mkmurali avatar namecheapmohan avatar powdahound avatar shoogland avatar svenharenburg avatar

Stargazers

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

Watchers

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

hipchat-cs's Issues

Unable to instantiate HipchatClient

I have previously implemented an avatar sync with your API wrapper but have noticed it has been failing for a while on the following line of code: -

HipchatClient hipchat = new HipchatClient(Properties.Settings.Default.HipchatAuthToken);

we are now getting this exception: -

System.AggregateException: One or more errors occurred. ---> System.MissingFieldException: Field not found: 'ServiceStack.Text.JsConfig`1.DeSerializeFn'.
   at HipchatApiV2.HipchatClient.ConfigureSerializer()
   at Impromptunet.Helpers.CronTasks.HipchatAvatarImages.Execute() in C:\BuildAgent\work\2b2f6d9b458403fb\Impromptunet\Helpers\CronTasks\HipchatAvatarImages.cs:line 23
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at FluentScheduler.TaskManager.<>c__DisplayClassf.<StartTask>b__d()
   at System.Threading.Tasks.Task.Execute()
---> (Inner Exception #0) System.MissingFieldException: Field not found: 'ServiceStack.Text.JsConfig`1.DeSerializeFn'.
   at HipchatApiV2.HipchatClient.ConfigureSerializer()
   at Impromptunet.Helpers.CronTasks.HipchatAvatarImages.Execute() in C:\BuildAgent\work\2b2f6d9b458403fb\Impromptunet\Helpers\CronTasks\HipchatAvatarImages.cs:line 23
   at System.Threading.Tasks.Task.Execute()<---

This started erroring at the end of August 2015

GenerateToken with GrantType.ClientCredentials leading to message "Authenticated requests only"

Hi,

I tried to use the GenerateToken method from the GenerateAuthToken test with my credentials. This leads to the following exception:

Test Name: GenerateAuthToken
Test FullName: IntegrationTests.GenerateAuthTokenExample.GenerateAuthToken
Test Source: c:\Users\fneumann\Downloads\Hipchat-CS-master-new\Hipchat-CS-master\src\IntegrationTests\GenerateAuthTokenExample.cs : line 12
Test Outcome: Failed
Test Duration: 0:00:02,289

Result Message:
HipchatApiV2.Exceptions.HipchatWebException : Message: 'Authenticated requests only. See https://www.hipchat.com/docs/apiv2/auth for more information.'
Type: 'Unauthorized'
---- System.Net.WebException : Der Remoteserver hat einen Fehler zurückgegeben: (401) Nicht autorisiert.
Result StackTrace:
bei HipchatApiV2.HipchatClient.GenerateToken(GrantType grantType, IEnumerable1 scopes, String basicAuthUsername, String basicAuthPassword, String username, String code, String redirectUri, String password, String refreshToken) in c:\Users\fneumann\Downloads\Hipchat-CS-master-new\Hipchat-CS-master\src\Api\HipchatClient.cs:Zeile 166. bei IntegrationTests.GenerateAuthTokenExample.GenerateAuthToken() in c:\Users\fneumann\Downloads\Hipchat-CS-master-new\Hipchat-CS-master\src\IntegrationTests\GenerateAuthTokenExample.cs:Zeile 19. ----- Inner Stack Trace ----- bei System.Net.HttpWebRequest.GetResponse() bei ServiceStack.Net40PclExport.GetResponse(WebRequest webRequest) bei ServiceStack.HttpUtils.SendStringToUrl(String url, String method, String requestBody, String contentType, String accept, Action1 requestFilter, Action1 responseFilter) bei ServiceStack.HttpUtils.PostToUrl(String url, String formData, String accept, Action1 requestFilter, Action1 responseFilter) bei HipchatApiV2.HipchatClient.GenerateToken(GrantType grantType, IEnumerable1 scopes, String basicAuthUsername, String basicAuthPassword, String username, String code, String redirectUri, String password, String refreshToken) in c:\Users\fneumann\Downloads\Hipchat-CS-master-new\Hipchat-CS-master\src\Api\HipchatClient.cs:Zeile 158.

Did anybody got this method properly working?

Best regards,

Frank

Set topic on room failing

Using the API like this:
var client = new HipchatClient(Token);
client.SetTopic("Room Name", "Topic");

I get the following failure:
HipchatApiV2.Exceptions.HipchatWebException:
Message: 'The request body cannot be parsed as valid JSON: Expecting value: line 1 column 1 (char 0)'
Type: 'Bad Request' ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at ServiceStack.HttpUtils.SendStringToUrl(String url, String method, String requestBody, String contentType, String accept, Action1 requestFilter, Action1 responseFilter)
at ServiceStack.HttpUtils.PutJsonToUrl(String url, String json, Action1 requestFilter, Action1 responseFilter)
at HipchatApiV2.HipchatClient.SetTopic(String roomName, String topic)
--- End of inner exception stack trace ---
at HipchatApiV2.HipchatClient.SetTopic(String roomName, String topic)
at UserQuery.Main() in c:\Users\test\AppData\Local\Temp\LINQPad_rzxmtrte\query_mamjej.cs:line 39

Private message history?

I'm sorry if this is not the correct place to ask this, but here goes,

I am trying to write an integration that can pull the history from a 1:1 conversation. It doesn't appear this is built into this library already...

Any recommendations?

Issue with latest version of ServiceStack

While updating to the latest version of Hipchat-CS 0.0.27 and ServiceStack.Text 4.0.23
I get the following runtime error: ServiceStack.Text.JsConfig.With(…) Method is missing?

Downgrading to ServiceStack.Text 4.0.18 solved the problem

Newbie Hipchat

Suggestion: working together with https://github.com/hugorodgerbrown/HipChat.net

Question: Can I use Hipchat and Powershell like Slash ?

https://gist.github.com/magnetikonline/11007e42d86f490b84f8

https://github.com/jgigler/Powershell.Slack/blob/master/Send-SlackMessage.ps1

http://geeks.ms/enterprise/2016/02/15/monitorizar-eventos-con-powershell/

function Send-SlackMessage([string]$message, [string]$userName, [string]$channel="#tests"){
$postSlackMessage = @{token="EL_TOKEN_SLACK_VIENE_AQUI";channel=$channel;text=$message;username=$userName;icon_url="ICONO.png"}
$body = Invoke-RestMethod -Uri https://slack.com/api/chat.postMessage -Body $postSlackMessage -method Post
}

$time=Get-Date
$time=$time.addHours(-1)
$section="Application"
$errors = get-EventLog -LogName $section -EntryType Error -After $time -Source "Application Error"

$errors | foreach {
$username=$env:computerName+": "+($.Source)+"(ID "+($.InstanceID)+")"
write-host $username
write-host "--------------------------------"
write-host $.Message
send-SlackMessage -message $
.Message -userName $username -channel "#tests"
}

Export chart possible

Using your Hipchat-CS will I be able to export the chat history from Hipchat server?

Missing Method Exception was Unhandled

Hello, I have an issue, when I use this line below:
"HipchatClient client = new HipchatClient();"

This is the exception:
_

An unhandled exception of type 'System.MissingMethodException' occurred in HipchatApiV2.dll

Additional information: Method not found: 'Void ServiceStack.Text.JsConfig1.set_DeSerializeFn(System.Func2<System.String,!0>)'.

_

I'm newbie with C#, and don't know how to make this work.

My imports:
using System;
using System.Runtime.InteropServices;
using HipchatApiV2;
using HipchatApiV2.Requests;
using Xunit;
using ServiceStack.Text;

NetCore

Any chance of making this net core compatible?

Method Not Found

Trying to do something really simple and get the following exception message:

var client = new HipchatClient("authtoken");
client.SendNotification("Remote Squadron Room", string.Format("Sending message to {0}", mailerMessage.ToAddresses));

{ "Message": "An error has occurred.", "ExceptionMessage": "Method not found: 'Void ServiceStack.Text.JsConfig1.set_DeSerializeFn(System.Func2<System.String,!0>)'.", "ExceptionType": "System.MissingMethodException", "StackTrace": " at HipchatApiV2.HipchatClient.ConfigureSerializer()\r\n at HipchatApiV2.HipchatClient..ctor(String authToken)\r\n at opie_mailer_api.Controllers.MailController.<Queue>d__3.MoveNext() in F:\\Users\\atatum\\Documents\\Visual Studio 2015\\Projects\\opie-mailer\\opie-mailer-api\\Controllers\\MailController.cs:line 45\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at opie_mailer_api.Controllers.v1_MailController.d__2.MoveNext() in F:\Users\atatum\Documents\Visual Studio 2015\Projects\opie-mailer\opie-mailer-api\Controllers\MailController.cs:line 79\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__31.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()" } `

ViewRoomHistory and ViewRecentRoomHistory are not able to handle the "from" attribute in cases where it is passed as a user object

ViewRoomHistory and ViewRecentRoomHistory are not able to handle the "from" attribute in cases where it is passed as a user object:

I am trying to fix an issue related to the specifics of the HIPChat API View room history and View recent room history:

Here, the “from” attribut may be either a user or just a string containing the name of the user.
I tried several options to handle this duality using the ServiceStack configuration but could not figure out an elegant way of solving this issue for the deserialization of the HipchatViewRoomHistoryResponse.

What is your recommendation to solve this issue?

Best regards,

Frank

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.