Accessing Resolution Class with JIRA SOAP API - c#

When a user closes a JIRA issue, they select a "resolution class" such as "User error", "service request", etc.
Is it possible to look at this field's value using the SOAP API? I looked at the "resolution" fields of my issues, but they are always blank if the issue is open and "6" if closed (so "resolution class" must not be the same as "resolution").
Any information would be much appreciated.

Ok. So you want to get 'Resolution Class' field values. It is more than likely a custom field. So you will have to find id of this field by using getCustomFields() where RemoteField.getName() == "Resolution Class". And then you can call getCustomFieldValues() on your issue to get a value of the custom field.

You are looking for getResolutions method.
RemoteResolution[] getResolutions(java.lang.String token)
throws RemotePermissionException,
RemoteAuthenticationException
Returns an array of all the issue resolutions in JIRA.
Parameters: token - the SOAP authentication token.
Returns: an array of RemoteResolution objects
Throws:
- RemotePermissionException - If the user is not permitted to perform this operation in this context.
- RemoteAuthenticationException - If the token is invalid or the SOAP session has timed out

Related

Trying to add a "SharepointDocumentLocation" to MS Dynamics365 via the Web API

I'm trying to create new Sharepoint document locations in my Dynamics365 (in the cloud) system, and I'm trying to link those to an existing Sharepoint Site (collection), as well as to a custom entity of my own.
I tried to do this:
POST /api/data/v9.2/sharepointdocumentlocations
Accept:application/json
Authorization: Bearer (valid JWT token)
Content-Type:application/json
OData-Version: 4.0
OData-MaxVersion: 4.0
{
"name": "WebDocuments",
"description": "Some useful description",
"sharepointdocumentlocation_parent_sharepointsite#odata.bind" : "sharepointsites(0f66e9e3-5dfc-ec11-82e5-0022489f9669)",
"relativeurl": "site",
"customEntity_SharePointDocumentLocations#odata.bind": "my_customentity(a654d179-ab61-ec11-8f8f-000d3a64d05c)"
}
but no matter what I try, I keep getting errors - mostly along the lines of:
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'sharepointdocumentlocation_parent_sharepointsite' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.
I have been researching and found several blog posts offering help - unfortunately, none of that has helped me solve my issue.
I tried to use various field names:
sharepointdocumentlocation_parent_sharepointsite#odata.bind
ParentLocationOrSite
and quite a few more - yet without any success.
Any ideas? How can I create a new Sharepoint document location in Dynamics365, and set its ParentLocationOrSite and RegardingObjectId properties in the POST request?
The correct syntax for that field should be:
parentsiteorlocation_sharepointsite#odata.bind
as you have another lookup pointing to a custom entity, I suggest to use my tool Dataverse REST Builder to create the Web API requests.

Error when creating JWT Token

As I am on my way to switch from using the legacy header authentication method to the JWT Token method, I have used the following example found here.
However, I get the following error :
Error calling Login: {
"errorCode": "PARTNER_AUTHENTICATION_FAILED",
"message": "The specified Integrator Key was not found or is disabled. An Integrator key was not specified."
}
Below is my C# code.
string oauthBasePath = "account-d.docusign.com";
string privateKeyFilename = "./private.pem";
int expiresInHours = 1;
ApiClient apiClient = new ApiClient(docuSignUrl);
apiClient.ConfigureJwtAuthorizationFlow(
"IntegratorKey",
"USER ID GUID",
oauthBasePath,
privateKeyFilename,
expiresInHours);
AuthenticationApi authApi = new AuthenticationApi(apiClient.Configuration);
return authApi.Login();
I have found this thread that shows the similar error but it doesn't seem resolved
Update 05/07/2018: I have validated the domain used in my account but I still get the same error message
Update 05/11/2018: When I use my code but that I replace the IntegratorKey, UserID and private key used in the DocuSign Unit Tests here, my code now works !? Hence, I can only conclude that the issue doesn't come from my code but maybe a configuration issue on the DocuSign side ? do I need to configure my Integrator Key a specific way ?
After more investigation, the reason with such an error is that I was not generating the Authorization Code Grant prior to executing my code.
Based on the information found here, I had to perform the following HTTPRequest example :
GET /oauth/auth?
response_type=token
&scope=signature
&client_id=YOUR_INTERGRATOR_KEY
&state=a39fh23hnf23
&redirect_uri=http://www.example.com/callback
Once it is approved, then I can run my code successfully.
In the end, the initial error message is really misleading (I might argue it could be considered a bug ?).

Unable to create Epic using JIRA cloud REST API (C#)?

I am working on a requirement where I need to create an 'Epic' issue type first and then I need to create a 'Bug' issue type mentioning the Epic name in it.
I am parsing the following data for adding an Epic in JIRA but its giving me an error:
string json = #"{""fields"":{""project"":{""key"":""SITBIT""},""summary"": ""Test Epic"",""description"": ""Test Epic Description"",""issuetype"": {""name"":""Epic""}}}";
The above code is giving me the below error:
The remote server returned an error: (400) Bad Request.
The above JSON code is working fine for normal issue type however its throwing an error if I changed the Issue type to 'EPIC'.
What could be the issue? How can I parse the JSON so that the epic can be added.
Secondly, When I am parsing the already added Epic name in the normal issue type then also it gave me (400) bad request error.
Different issue types can have different required fields. To create an epic you also need to specify the 'Epic Name', but this field is missing in your request.
You can use the JIRA REST API to verify which fields are required using the /rest/api/2/issue/createmeta resource:
The fields that can be set on create, in either the fields parameter or the update parameter can be determined using the /rest/api/2/issue/createmeta resource. If a field is not configured to appear on the create screen, then it will not be in the createmeta, and a field validation error will occur if it is submitted.
The JIRA REST API documentation also contains more info about how errors are handled. You only mention the message that corresponds to the status code of the response, but the response body will contain more info, for example:
{
"errorMessages": [
"Field 'priority' is required"
],
"errors": {}
}

WebAPI 2: new http code needed for inactive accout login process failure

Im creating a WEBAPI-2-based system with users, which are inactive after registration and they need to be activated before login to system. Im wonderig how to implement ACTIVATION process properly using good/proper pattern. My questions are the following:
What HTTP code should be returned?
I was planing to add new one like 420, but I dont know if I can use it. It's not belonging to enumaration HttpStatusCode? Or should be used the existing HTTP error code, which one?
Can new HTTP error code be added to HttpStatusCode enumeration, probably not?:)
What class should be used to return a result?
I want to return Activation Failure HTTP code (header) + id of user (body) ?
UPDATE1:
HttpStatusCode.Conflict - can this http-errorcode be used when user fails to login to unactivated account?
Why not return 200, and add msg at content.

MS CRM 4.0 CrmService - Close a Task

I'm trying to work out how to use the CrmService to close a Task in MS CRM 4.0
I've tried to use the SetStateTaskRequest to set a Task's state and status to TaskState.Completed and 5. I also tried TaskState.Completed and -1, but no dice there either.
Either way, I only receive the ever-helpful "Server was unable to process request" exception on the CrmService.Execute attempt.
I can create and update Tasks as freely as I please. But I can't seem to set them to completed. It's frustrating.
I noticed that I can only set the state of a Task to Completed in CRM through the Close Task action. I was wondering if there is a separate CrmService call that I need to make to perform the Close Task action, rather than going through the CrmService.Execute method.
Oh: I'm logging into the CrmService with full permissions. So I can't see that it would be a permissions issue on the task item.
I can't think what else could be causing this issue. Any advice or even just a point in the right direction would be very much appreciated.
FIRST EDIT:
Thanks to grega g's answer for getting me to check the Detail field of the exception.
I now have a more detailed exception message. In XML Form:
<error>
<code>0x80040203</code>
<description>Invalid format of input XML for request SetStateTask: required field 'EntityId' is missing.</description>
<type>Platform</type>
</error>
Which is bizarre - consider my code (almost identical to greg g's:
SetStateTaskRequest request = new SetStateTaskRequest();
request.EntityID = gTaskId;
request.TaskState = TaskState.Completed;
// ETaskStatusCode is an enumeration of the status codes taken from the StringMap in CRM.
//
// ETaskStatusCode.Completed = 5 - I can confirm this is the accurate status value for a Closed Task.
//
// Also, I have attempted this code with -1, which the documentation claims should cause the status
// to automatically be set to the default status for the supplied state. No change there.
request.TaskStatus = (int)ETaskStatusCode.Completed;
SetStateTaskResponse response = CRMManager.CrmService.Execute(request) as SetStateTaskResponse;
Also, just to confirm that I have the right status code (and also share something I've found very useful when dealing with MS CRM), here's the SQL I use to determine the values for entity statuses.
SELECT
MSE.ObjectTypeCode,
MSE.PhysicalName,
SM.AttributeName,
SM.Value,
SM.AttributeValue
FROM MetadataSchema.Entity MSE
INNER JOIN StringMap SM on MSE.ObjectTypeCode = SM.ObjectTypeCode
ORDER BY MSE.PhysicalName, SM.AttributeName, SM.AttributeValue
I can confirm from the MS CRM web interface that the Status value that is associated with a Completed task is also named Completed. I can confirm from the SQL above that the value of this status, for a Task, is 5 - this is the value passed in from my Enum.
I can also confirm that gTaskId is being set to a valid Guid that references a Task that actually does exist, and is open at the time the close is attempted.
Curiouser and curiouser. Any thoughts?
Use SetStateTaskRequest class.
SetStateTaskRequest task2Close = new SetStateTaskRequest();
task2Close.EntityId = <taskGuid>
task2Close.TaskState = TaskState.Completed;
task2Close.TaskStatus = <some value>
try
{
SetStateTaskResponse r = (SetStateTaskResponse) crmSvc.Execute(task2Close);
}
catch (SoapException e)
{
//Use e.Details for more info than "server was unable ..."
}
This code should work (or let you see why error occurs)
Are you sure that when you are trying to close task you're passing status value which is valid for Completed state? Different status codes are only valid with their corresponding state codes. Can you add your source code and a portion of your state entity customization?
Found it!
Okay - reviewing my code above and the error message closely, my CrmService contained the property EntityID - but the exception was that the property EntityId was missing.
Somehow, my CrmService had its EntityId property renamed to EntityID.
Renaming the property fixed the problem. I still have no idea how that happened in the first place.
To be safe, I'll regenerate a new Service proxy to make sure that my properties are correctly named.
Looking through the code, it seems that someone did a find-and-replace on 'Id' and turned it into 'ID' - which incidentally is the naming convention in my workplace for Property fields that represent primary keys.
Thanks again to grega g for pointing out that the Detail property had the extra information I needed.

Categories

Resources