ithielnor / harvest.net Goto Github PK
View Code? Open in Web Editor NEWHarvest API wrapper in .Net.
License: MIT License
Harvest API wrapper in .Net.
License: MIT License
I'm trying to import invoices from harvest but response from Api have Currency field null for GBP , INR may be for others also.
Need to go through all the classes in /models
and provide basic documentation.
Documentation can mostly be copy-pasted from http://help.getharvest.com/api/
It would be great to have Async versions of all API methods that return Task
/Task<T>
to support async
and await
. RestSharp already supports this so it wouldn't be much work. Would likely involve a little refactoring so that the Async methods aren't full duplicates of the synchronous methods.
I'd be happy to work on this, as I have done this for other projects.
Having a few issues with clients who are set to non-USD currencies.
Nothing is returned when the client is set to AUD, but it returns the results fine when clients are set to USD.
Any tips or tricks around this?
Thanks!
Are you planning to support .net core?
I know restsharp does not have .net core support yet.
seems a small misspelling?
should be DayEntry.AdustmentRecord ?
or am I missing somthing here? tx
User model doesn't have a property to read the WeeklyCapacity. Please let us know if this is part of another object. Thanks
See below json we got from harvest /people API call:
"user": {
"id": 885498,
"email": "[email protected]",
"created_at": "2014-12-12T16:18:54Z",
"is_admin": false,
"first_name": "test",
"last_name": "test",
"timezone": "Kyiv",
"is_contractor": false,
"telephone": "",
"is_active": true,
"has_access_to_all_future_projects": false,
"default_hourly_rate": 0,
"department": "(Ukraine) QA",
"wants_newsletter": false,
"updated_at": "2017-02-06T11:20:32Z",
"cost_rate": null,
"weekly_capacity": 144000
}
The xml is getting returned properly from the API, however, the T Execute method in HarvestRestClient.cs is not returning any data for projects. Is there something off with the serialization?
The UserId, ProjectId, and TaskId properties on DayEntry are int
but the corresponding Id properties on the User, Project, and Task types are long
. These properties on DayEntry should be changed to long
accordingly.
I'm getting nulls when calling ListProjectEntries
and using OAuth2 authentication. Looks like the issue is the way the URL is constructed when using OAuth2. Using Fiddler, I can see that the call returns a 401 error from Harvest with the following data:
{"error":"invalid_token","error_description":"The access token provided is expired, revoked, malformed or invalid for other reasons."}
The URL that gets generated for the call seems to be incorrect. The access_token parameter adds a second ?
to the URL; example below (from Fiddler, edited to remove token):
/projects/removedprojectid/entries?access_token=removedaccesstoken?from=20150801&to=20150831
As you can see, there two ?
in the constructed URL. Removing the second question mark and calling manually does work.
I have seen that this exact issue has been closed before, but i'm still getting the issue.
HarvestRestClient hclient= new HarvestRestClient("subdomain", "[email protected]", "password");
var projects= hclient.ListProjects();
The variable projects is null since hclient.ListProjects() returns null.
Please Change the Change the CHF Currency to [Description("Swiss Franc - CHF")]CHF then it should work.
Currently too many tests rely on a connection to a live harvest account. Use mocking and compiled xml bodies to make the tests truly "unitized".
Version 0.9 parameter was named "Admin" and pulled the correct bool.
Version 0.10 now named "IsAdmin" and is now broken, pulls false on an admin account.
If you issue a CreatePayment using the following method:
HarvestRestClient _client = new HarvestRestClient(subDomain, email, password);
_client.CreatePayment(invoiceId, invoiceAmount, DateTime.Now);
That will work normally. However, if you do:
HarvestRestClient _client = new HarvestRestClient(subDomain, clientId, clientSecret, clientToken);
_client.CreatePayment(invoiceId, invoiceAmount, DateTime.Now);
That will fail with a 500 response from harvest due to the way that RestSharpFactory.cs constructs the RestClient, more specifically the ParameterType of access_token. Since access_token is set to be GetOrPost, this will result in the whole request being thrown away and the RequestBody will instead just contain access_token=<token>
According to the RestSharp documentation:
If you have GetOrPost parameters as well, they will overwrite the RequestBody โ RestSharp will not combine them but it will instead throw the RequestBody parameter away.
We can test a solution to this this using reflection by setting ParameterType to QueryString:
HarvestRestClient _client = new HarvestRestClient(subDomain, clientId, clientSecret, clientToken);
var cli_field = typeof(HarvestRestClient).GetField("_client", BindingFlags.NonPublic | BindingFlags.Instance);
RestClient _iclient = (RestClient)cli_field.GetValue(_client);
_iclient.DefaultParameters.Where(p => p.Name == "access_token").First().Type = ParameterType.QueryString;
_client.CreatePayment(invoiceId, invoiceAmount, DateTime.Now);
And now it works :)
I'm working on the async changes from #47 and I'm wondering if it's okay to use C# 6 features, primarily string interpolation and the nameof operator. This would require the project to be built with VS2015.
For the HarvestRestClient.Execute method, when response.StatusCode == System.Net.HttpStatusCode.BadRequest, I suggest throwing the response.Content which includes Harvest's error message.
I'm getting exceptions trying to use CreateDaily. The same parameters sent directly against the API using DHC work fine and return a 201:
Test api support 1 7925148 4218975 5/1/2015 12:00:00 AMI'm going to download the project and try to debug the issue. If anyone has any insight of workarounds please let me know!
Currently the exception only includes the response metadata. However, Harvest inserts the specific error message in the content body.
budget-by value, "Person" returned an error from Harvest, but "person" (lowercase) did not. I suggest converting the BudgetMethod enum to lowercase.
Seems DayEntry.StartedAt en EndedAt output DateTime.Now as the Date part of the DateTime instead of the actual Date the entry was tracked?
Hi,
When I call client.ListClients() it is always returning a null value.
I have fiddler running and when the method is executed it is sending the request and responding with a list of clients in xml format.
client.ListProjects works fine. It returns a populated list of Projects. In Fiddler the request headers look exactly the same and both are returning xml.
Any ideas?
Thanks!
Running this:
var client = new HarvestRestClient("subdomain", "[email protected]", "password");
return client.ListProjects();
is returning null.
Because the .dll in the NuGet package isn't signed, it's a real pain to try and use it when I need signing.
It seems that the only package dependency is RestSharp, and they maintain a signed version of their package with the name RestSharpSigned.
I would love to see this implemented!
Hi
i am developing code for a client to get time logs . when i am tring to get data from the url "https://subdomain.harvestapp.com/projects" , am getting data in post man, but when i the same
HarvestRestClient client = new HarvestRestClient("subdomain", "[email protected]", Password); and client.ListProjects(), am getting null value. am using Harvest.Net nuget package.
i am getting data for ListContacts and ListTasks, Not for ListClients, ListProjects
Please help
Thanks
Arun skaria
The ListProjects call is returning a 200 status code, but null data. I've tested on DHC hitting the Harvest API directly and it's returning results.
I just implemented a bunch of this myself over the weekend and went to submit to NuGet when I found that it already existed! Would be great if this was listed at:
Updating RestSharp breaks the code. Just a point worth mentioning.
When I run the following code:
HarvestRestClient hclient= new HarvestRestClient("subdomain", "[email protected]", "password");
var expenses = hclient.ListExpenses();
The expenses variable contains an empty list, however there are expense records when checked on the website. When looking at the Harvest API official documentation there is no way to view all expenses, thus I just want to ask if there is a way to do this through the wrapper.
In testing our integration with Harvest.net, we're getting exceptions in the HarvestXmlDeserializer. When I inspect the actual values, I find that the EstimateMethod is being populated with the same value found in BudgetMethod. When BudgetMethod is not 'none', the deserialization is failing.
Harvest seems to change the descriptive text on the currency enumeration pretty frequently. We need to make this more robust, perhaps by splitting the description into parts and deserializing based only on the acronym.
Currently we automatically load resources from the Location header on PUT and POST responses. I'm thinking this is a waste, when we usually only need the ID of the new object.
As part of 2.0 I think it should only make one request and return the details of the Location header instead of requesting it.
At the Moment it's not possible to approve or mark a time entry as invoiced. According to the following page (http://help.getharvest.com/api/timesheets-api/timesheets/adding-updating-time/), it should be a really small change: to the UpdateDaily Method and DailyOptions Model.
Can you add that functionality?
Currently there are only a handful of methods available in the IHarvestRestClient
. In order to write tests and mock the HarvestRestClient
methods using a framework like MOQ, the Resource methods need to be included in the interface. This would allow for easier testing using this library.
The authenticated client is pulling a null Project from an active projectId.
Currently the HarvestRestClient only throws a HarvestException if the status code is 400 Bad Request. In the event of a different error status code, such as 503 if you've been rate limited or perhaps an unexpected 500 server error, the method just returns null and doesn't let the calling code know about the reason for the failure.
I'm submitting a PR for this shortly.
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.