"Priority: cannot be blank" error while creating ticket - api

I am trying to create a request /api/v2/requests.json
below is my data:
{
request: {
Priority: "Normal"
comment: {body: "test"}
from_mail: "pk#abccd.com"
subject: "test"
}
}
Auth token is correct but I am always getting the below error:
responseJSON: {error: "RecordInvalid", description: "Record validation errors", details:
responseText: "{"error":"RecordInvalid","description":"Record validation errors","details":{"base":[{"description":"Priority: cannot be blank","error":"BlankValue","field_key":360012833834}]}}

The documentation can be found here.
Your mismatching fields:
Priority vs priority with content Normal vs normal
from_mail doesn't exist - recipient maybe?
I am not pretty sure if it's case sensitive, but that seems like an obvious mistake here.

Related

Mule design centre defining 400 response but trying it does not return same response

I am defining my api contract in RAML in Mule Anypoint platform Design centre .
Here is the simple contract :
#%RAML 1.0
title: test_experiment
version: v1
mediaType: application/json
/test:
put:
headers:
trackingId:
type: string
description: "Track each request"
minLength: 3
responses:
200:
body:
application/json:
example:
{
"msg": "successfully done"
}
400:
body:
application/json:
example:
{
"msg": "something bad was submitted",
"id" : "001"
}
Next I am trying to 'test it' in Documentation tab and when I purposefully do not enter a trackingId I do get a 400 response code but the response payload is different.
I have defined the response payload as : ( expected payload )
{
"msg": "something bad was submitted",
"id" : "001"
}
However the payload response in 'try it' in design centre is :
{
"code": "REQUEST_VALIDATION_ERROR",
"message": "Error validating header: expected minLength: 3, actual: 0"
}
So why is the 400 response not being returned as I have it defined in my raml ?
Edit1 : This behaviour is all observed in Design Centre , I am not providing an implementation and then testing it , I am using design centre Documentation and 'Try it' feature as per image below :
Because it is a mock, not a real implementation. When you are testing in Design Center you are using the Mocking Service that simulates reponses. The error you are getting is because the request doesn't match with the specification. The Mocking Service usually uses only the first status code it finds in the API RAML. If you want it to return your error use a behavioral header like MS2-Status-Code to set the error code. For example set the header MS2-Status-Code to 200,400. Although I'm not sure it will work to override the validation error from the Mocking Service. You will need to try.

How to check if ID in the URI is null and throw an error?

I tried to check if a specific URL doesn't specified an ID
This are what I've got so far:
http://localhost:8082/orders/1234 ---- Success!
http://localhost:8082/orders/ ---- URL not found!
I want to throw and error something like "Id not specified!" not a URL not found.
Look at Validation Module
Look at the "Matches Regex" section down.
I have not tried it
Hope it may help
the believe the best approach for you is to start using RAML. you can design the endpoint in RAML and specify what error to be thrown if the request is not a match.
/{order_id}:
get:
description: Get a Order by id
responses:
200:
body:
application/json:
type: Foo
example: !include examples/Order.json
400:
body:
application/json:
type: Error
example: !include examples/Error.json
in the above RAML definition if there is no orders/{order_id} you will get a http 400 returned.
Define a custom error handling and that will return error description alongside other required data
set status code 400 in a variable, map fields as per below example.
ex:
{
"error": {
"errorCode": "NOT_FOUND",
"errorDateTime": "2019-10-10T14:00:46",
"errorMessage": "The requested API cannot be found, ID is not specified",
"errorDescription": "Description: /orders"
}
}

"error trying invoke chaincode. Error: chaincode error (status: 500, message: TypeError: cannot read property 'getFullyQualifiedIdentifier' of null)",

I am getting below error while following tutorial here.
https://hyperledger.github.io/composer/unstable/managing/current-participant.html
I have created one Participant and issued identity to it. But in my transaction processor function,when I verify the participant ID of the current participant by using the getCurrentParticipant function through rest apis I get below error.
{
"error": {
"statusCode": 500,
"name": "Error",
"message": "error trying invoke chaincode. Error: chaincode error (status: 500, message: TypeError: cannot read property 'getFullyQualifiedIdentifier' of null)",
"stack": "Error: error trying invoke chaincode. Error: chaincode error (status: 500, message: TypeError: cannot read property 'getFullyQualifiedIdentifier' of null)\n at _initializeChannel.then.then.then.then.catch (/home/praval/.nvm/versions/node/v6.11.1/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:847:34)"
}
}
Can anybody explain the reason?
It looks like the mapping from certificate to participant is not in place. The easiest way to test this is to use the composer identity issue command and then use composer network ping -- which will return the current participant. Once that is working then getCurrentParticipant() should work.
https://hyperledger.github.io/composer/managing/identity-issue.html
When you composer network ping your participant will try to access the network metadata. The ACL rule below will permit this access. Please ensure that you are using the latest version of the basic-sample-network which includes this rule.
rule SystemACL {
description: "System ACL to permit all access"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}

Format for exceptions and errors from Yodlee REST Aggregation API

What is the best way to catch exceptions in the response payload for API calls made to the Yodlee REST Aggregation API?
Historically speaking I've seen {'Error' => [{'errorDetail' => 'some error message'}]}, but I've also seen {'errorOccured' => true, 'exceptionType' => 'some documented exception type', 'referenceCode' => ''}.
The documentation suggests I can expect exceptionType, but I'd like to be sure. The API call I'm currently most concerned with is /login.
Here are types of error code format which you can expect-
JSON exception format 1:
{
"errorOccurred": "true",
"exceptionType": "com.yodlee.core.SiteNotFoundException",
"referenceCode": "_afe4ae60-68fe-4443-a721-d97a192e9455",
"message": "Argument value not found: 164413432"
}
JSON exception format 2 (Same as format 1, but "message" attribute is missing so considered as additional):
{
"errorOccurred": "true",
"exceptionType": "Exception Occurred",
"referenceCode": "_5c4d1347-cb4a-4404-809b-57dbfabcf1db"
}
JSON exception format 3:
{
"Error": [
{
"errorDetail": "No session ID found "
}
]
}
JSON exception format 4 (Same as format 3, but "errorDetail" attribute is missing so considered as additional):
{
"Error": [
null
]
}
JSON exception format 5:
{
"errorDetail": "Token authentication failed for cobrand/user Invalid cobrand conversation credentials"
}
This will cover almost all the scenarios.

Paypal Internal Server Error Rest approval Payment

I have a problem when creating an approval Payment using REST API.
i'm creating a payment with pyment_method = 'paypal'
while i'm sending to paypal server my json file as
"{"transactions":[
{"amount":{"currency":"USD","total":"12","details":{}},
"description":"This is the payment transaction description."}
]
,"links":[],
"intent":"sale","payer":{
"funding_instruments":[],"payment_method":"paypal"}
}"
this is
result: Object
debug_id: "086b180fbe2f1"
information_link: "https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR"
message: "An internal service error has occurred"
name: "INTERNAL_SERVICE_ERROR"
Paypal frequently returns internal server error. This is common in sandbox mode.
The most common is to try again and get execute.
Try:
https://github.com/paypal/rest-api-sdk-nodejs/issues/1
You are including elements you shouldn't be, and missing important ones. If you are setting up a PayPal payment you need to have cancel and return urls:
{
"redirect_urls":{
"return_url":"http://<return URL here>",
"cancel_url":"http://<cancel URL here>"
},
"transactions":[
{
"amount":{
"currency":"USD",
"total":"12.00"
},
"description":"This is the payment transaction description."
}
],
"intent":"sale",
"payer":{
"payment_method":"paypal"
}
}
See Accepting a PayPal Payment for a guide
In my case I set the Content-Type header to application/json and get meaningful response:
{"name":"MALFORMED_REQUEST","message":"Incoming JSON request does not map to API request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST","debug_id":"688b8ab4b2895"}
Instead of:
<ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.lang.NullPointerException</ns1:faultstring></ns1:XMLFault>