I'm trying to issue a POST to create a worklog to no avail. I've tried using a HttpWebResponse (from this sample) which didn't work (same error) and I'm now using WebClient (from this sample)
My data I'm sending is:
{ "timeSpent": "25m", "started": "2014-11-13T01:41:46.8508000-0600", "comment": "Logged via webhook" }
My code is basically the following:
where queryInfo is object with property values of {{ Url = "issue/{{issueId}}/worklog", Data = JObject.FromObject( new {{ .. }} ) }}
using ( var client = new HttpClient() ) { client.BaseAddress = new Uri( @"https://benefittech.atlassian.net/rest/api/2/" ); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( "application/json" ) ); client.DefaultRequestHeaders.Add( "Authorization", "Basic " + Convert.ToBase64String( Encoding.Default.GetBytes( "myUser:myPassword" ) ) ); if ( queryInfo.Data != null ) { var response = await client.PostAsJsonAsync( queryInfo.Url, queryInfo.Data ); response.EnsureSuccessStatusCode(); var url = response.Headers.Location; Console.WriteLine( string.Format( "POST Response for {0}: Url={1}", queryInfo.Url, url ) ); } }
And I always get "500 (Internal Server Error)". Any suggestions on how to debug? Note that I've successfully used HttpClient (and the header/address stuff) to do a GET and receive correct information.
Community moderators have prevented the ability to post new answers.
Thanks for the info. I tried with { "timeSpent": "25m", "started": "2014-11-13T02:34:29.000-0600", "comment": "Logged via webhook" } and now I get 400 (Bad Request). :(
Yeah, I think the date format has to be literally "YYYY-MM-DDTHH:MM:SS.000+TZTZ" so in your case: "2014-11-13T01:41:46.000-0600" -- only the seconds decimals changed. Try that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.