set default error messages for mutations in Hasura - api

I am using the Hasura console. If I get an error, I see a message like this:
{
"errors": [
{
"extensions": {
"path": "$.selectionSet.insert_one.args.object",
"code": "constraint-violation"
},
"message": "Uniqueness violation. duplicate key value violates unique constraint \"vehicle_number_plate_key\""
}
]
}
Is there any way that I can use the console to set a custom error message? I couldn't find any such option on the console.

Not sure if there is a way to customize the error messages that are generated by Hasura.
However, if this is to be consumed by a single frontend client, you can just let the frontend client define its own error messages.
This is also practical to support multi-language error messages if the need arises.

Related

How do I fix the problem behind "THIRD_PARTY_AUTH_ERROR" when using Google's API Explorer to send a Firebase Cloud Messaging message?

I am trying to create a very simple Web app that can send and receive messages (including Push notifications) via Firebase Cloud Messaging. I want to try testing the ability to receive test messages sent from the Google API Explorer. However, I am running into a curious error as just about any API call from the relevant API URL will return the following error:
{
"error": {
"code": 401,
"message": "Auth error from APNS or Web Push Service",
"status": "UNAUTHENTICATED",
"details": [
{
"#type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "THIRD_PARTY_AUTH_ERROR"
}
]
}
}
For reference, here is the message that I am trying to send:
{
"message": {
"token": "[FCM_TOKEN]",
"notification": {
"title": "New Notification",
"body": "Sample Text"
}
}
}
I also note that when I add "validate_only": true to the message, that the error goes away and the send request succeeds (though this is of no help, as that disables actually sending the message).
I am stumped, becuse the hint that pops up suggests that my OAuth2 credentials are invalid, though I leave the OAuth2 credential option checked and go through the authorization popup to provide my credentials.
Are you running the web app on Firefox, perhaps?
I have been running around my tail with this same issue for days now, and today I've found that there is an issue on Firefox, while this does work on Chrome:
Similar stack overflow question
The issue on the Firebase repository on Github
Although not a proper answer, I hope this helps.

Return less information for JSON parser errors

Using asp.net core 3.1 for a web api, my problem is that when a request comes in with some invalid parameters, the framework produces an error message that I don't want returned in the response.
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|968ad6dd-4488d8bc10ec5760.",
"errors": {
"$.value": [
"The JSON value could not be converted to System.String. Path: $.value | LineNumber: 1 | BytePositionInLine: 15."
]
}
}
Is it possible to change this error response to something else? Ideally, I'd want to reduce the verbosity and not return the error message ("The JSON value could not be converted to System.String").
app.UseExceptionHandler does not work. ExceptionMiddleware does not work because await _next(httpContext); does not throw an exception.
Thank you in advance.
It seems that one possible way is to play with this: https://github.com/dotnet/aspnetcore/blob/5ff9ed68d1cf6c89d72d27a69b00ed0ecd34daed/src/Mvc/Mvc.Core/src/Infrastructure/ModelStateInvalidFilter.cs
Either set _apiBehaviorOptions.SuppressModelStateInvalidFilter or create a custom InvalidModelStateResponseFactory. Haven't tried it yet, but seems like a potential solution.

Mimecast API authentication issue

trying to connect to endpoint with all needed headers defined:
https://us-api.mimecast.com/api/login/login.
Error message receieved : 0018 Client update required
Did anyone encounter/solve this issue?
{
"meta": {
"status": 401
},
"data": [],
"fail": [
{
"key": {
"username": "datadash#itprosusa.com",
"tokenType": "key",
"verifyOnly": false
},
"errors": [
{
"code": "err_xdk_client_update_required",
"message": "0018 Client update required",
"retryable": false
}
]
}
]
}
I came across the same error message when trying to get Access key and Secret Key. You can actually get these in the Mimecast portal UI by going to: Administration | Services | APIĀ Applications, then Add API Application fill in the details and wait 30 minutes. After 30 minutes click on your newly created API application and select Create Keys, fill in the required information and it will provide you with your Access key and Secret key used for API calls.
If this doesn't answer your question or help you I would suggest getting in contact with Mimecast Support, they are usually pretty good!

Amadeus API returns Internal error with all requests (Production Key)

{
"errors": [
{
"code": "38189",
"title": "Internal error",
"detail": "An internal error occured, please contact your administrator",
"status": "500"
}
]
}
I get this error when I use production key to send requests to AMADEUS API, this error returns just with production key but not with test key. Despite I updated header to " Accept application/vnd.amadeus+json" the error still returns.
Here one of the requests:
https://api.amadeus.com/v1/shopping/flight-offers?origin=MAD&destination=PAR&departureDate=2019-08-01&adults=1&nonStop=false&max=6
We had a configuration issue on our side. Everything has been fixed, You should be able to use all the APIs in production.
Sorry for the inconvenience.

Google Sheets API not accepting my API Key

I generated an API key through Google Developer's Console. I am trying to read data from a Google Sheet.
However when I do a GET request using the following link:
https://sheets.googleapis.com/v4/spreadsheets/1nUeRttOMn--b46Vt7FIlU_eoOqvvuOyukAEg2L_UGQQ/values/A1%3AF500?key={abcdefghijklmnopqrstuvwxyz0123456789}`
I get the error message:
API key not valid. Please pass a valid API key.
Full error:
{
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developers console",
"url": "https://console.developers.google.com"
}
]
}
]
}
}
My API Key is valid. How can I resolve the error? I plan to make the API call via Alteryx.
Use this URL:
https://sheets.googleapis.com/v4/spreadsheets/PUT YOUR SHEET ID HERE/values/PUT YOUR SHEET NAME HERE (sheet name not spreadsheet name)?key=PUT YOUR API KEY HERE
I was going through the same error. The Key was valid and I even changed the keys but it was not working.
Here's what I did,
Before the error, it looked like this...
https://sheets.googleapis.com/v4/spreadsheets/PUT YOUR SHEET ID HERE/values/Sheet1?valueRenderOption=FORMATTED_VALUE&key=PUT YOUR API KEY HERE/HTTP/1.1
Then I removed the last bit and got the valid response.
https://sheets.googleapis.com/v4/spreadsheets/PUT YOUR SHEET ID HERE/values/Sheet1?valueRenderOption=FORMATTED_VALUE&key=PUT YOUR API KEY HERE
Worked like a charm!