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": {}
}
Related
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.
I am currently trying to handle the exception, when a subscription request can't be validated in time, using the Graph SDK. Unfortunately i am not really sure how to achieve this. The exception thrown when a subscription isn't validated in time is:
Microsoft.Graph.ServiceException: Code: InvalidRequest
Message: Subscription validation request failed. Must respond with 200 OK to
this request.
The HttpStatusCode in the ServiceException is "BadRequest" but just this isn't enough to distinguish the error from other common errors since i want to handle them differently. The ServiceException also contains an Error property with a string property called "Code", which contains "InvalidRequest" in my case. The GraphErrorCode enum in the Graph SDK contained this code so i used it with the "IsMatch" method in the ServiceException:
catch (ServiceException serviceException)
{
var invRequest = GraphErrorCode.InvalidRequest.ToString();
if(serviceException.StatusCode == HttpStatusCode.BadRequest)
{
if (serviceException.IsMatch(invRequest))
{
// do something
}
}
}
"InvalidRequest" is defined in the graph documentation as:
The request is malformed or incorrect.
Considering this i still think my ErrorHandling isn't enough to just catch this specific error.
What i want to know is:
Is using the "GraphErrorCode" enum even correct.
Is there a way to handle this specific error without just comparing the exception message ("Subscription validation request failed. Must respond with 200 OK to this request") with a hard coded string.
You're referencing an outdated library (by over 2 years). The correct SDK for this is the Microsoft Graph .NET Client Library. It includes an far more recent error code enumeration.
As for processing the error, the code is typically enough for handling exceptions. The message content is useful for debugging since it often includes more granular information (what exactly failed, which properties were invalid, etc.). My general rule of thumb is to use the code for handling errors but log both code and message properties for debugging.
The import piece to understand is that different endpoints may surface the same error code for different reasons. A BadRequest may mean something different when issuing a GET against a user resource than it does when issuing a POST to /events. Your handler should take into account both the action and the error.
Here is an example error returned when sending an invalid request (/v1.0/me/a):
{
"error": {
"code": "BadRequest",
"message": "Unsupported segment type. ODataQuery: users/48d31887-5fad-4d73-a9f5-3c356e68a038/a",
"innerError": {
"request-id": "fd4c8b27-26af-4b07-a5be-5efb139d1eb7",
"date": "2018-05-22T14:39:02"
}
}
}
If all I handled was the BadRequest, my handler would likely sufficient. I can handle the error and keep the user moving forward. In my log however I store both BadRequest and Unsupported segment type. ODataQuery: users/48d31887-5fad-4d73-a9f5-3c356e68a038/a so that I can properly file a bug in the code.
Another option might be to do some additional parsing. Lets say that /a doesn't always return an error. Maybe /a works fine for AAD accounts but not for MSA users (FTR, /a is entirely fictitious). If this were the case, I might also want to parse the message and see if the BadRequest included "Unsupported segment type" and handle it a bit differently than a BadRequest that didn't include that message.
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 ?).
I am trying to create a new Story asset through the V1 API. I am receiving an error:
"Unhandled Exception: VersionOne.SDK.APIClient.ConnectionException: Error writing
to output stream ---> System.Net.WebException: The remote server returned an er
ror: (400) Bad Request. ---> VersionOne.SDK.APIClient.APIException: Violation'Re
quired'AttributeDefinition'Super'Story"
I am setting up my connector and creating the asset like so:
V1Connector connector = V1Connector
.WithInstanceUrl("xxx")
.WithUserAgentHeader("NewApp", "1.0")
.WithAccessToken("xxx")
.UseOAuthEndpoints()
.Build();
IServices services = new Services(connector);
Oid projectId = services.GetOid("Scope:02284");
IAssetType storyType = services.Meta.GetAssetType("Story");
Asset newStory = services.New(storyType, projectId);
IAttributeDefinition nameAttribute = storyType.GetAttributeDefinition("Name");
newStory.SetAttributeValue(nameAttribute, "My New Test Story");
services.Save(newStory);
The error is given on the last line. I've been trying to figure this out for a while and I haven't come up with a solution. Does anybody have suggestions?
Here is a link to the example I am trying to follow: https://community.versionone.com/VersionOne_Connect/Developer_Library/Get_an_SDK/.NET_SDK/Creating_Assets
Violation'Required'AttributeDefinition'Super'Story exception is being thrown because you are attempting to create a Story asset without populating the required field, 'Super'. Someone in your organization made this a required attribute.
See your VersionOne project administrator or populate this attribute with a valid value. In order to determine if there are other required fields, do a meta query and any attributes with the '*' next to it is required. As you can see in this png, Name and Scope are my only required attributes.
When you look at your meta data, you will see that Super is a relation to an Epic.
There are two places that you can learn about VersionOne Metadata
1) http://community.versionone.com/VersionOne_Connect/Developer_Library/Learn_the_API/Meta_API
2) http://YourVersionOneInstance/help/api
btw, a Story meta query url has a shape like this
https://YourVersionOneInstance/meta.v1/Story?xsl=api.xsl
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