Mulesoft error message propagation through deployed application - api

General explanation of the problem:
how can i get/log inside an application B, the error/exception message produced by an application A (error description and code are generated with a OnErrorPropagate). Application A is a Process API and B is an Experience Api both deployed on cloudHub.
More Details:
i have a Process API App. and a Experience API APP. deployed on CloudHub that retrieve client data from a DB.
.../getClient?client_Id=xxx
When inside the request the client_id params is not provided the below error message (generated inside an OnErrorPropagate) is shown
"message" : "bad request"
When a client call the Exp.API APP /getClient without the parameter, the PROCESS API APP (invoked by a flow inside the Exp.API implementation) respond with the above error message.... how can i retrieve this message in my Experience API Application?
If i try lo log the payload response (that should contain the error message) from an Experience API APP log, i always get an empty message.
So, is possible to pass an error message generated inside an OnErrorPropagate from an application (PROCESS API APP) to another app (EXPERIENCE API APP)?
All these applications are on cloudhub. Mulesoft 4

You can capture the the error response payload from the process API which will be present in the error object and set it as response for your experience API using this DW expression
#[output application/json --- error.exception.errorMessage.typedValue]

You should capture the payload response in the Experience API when you make the HTTP request to the Process API.

Related

SAP Cloud SDK JS receives empty data from Enterprise Messaging Queue

I have build a simple cloud-SDK based application for adding as a Webhook in Enterprise messaging queue to receive the events as soon as it gets inside the queue.
I have an OPTIONS and POST function. OPTIONS is for the handshake with the queue and it works.
Now, when there is message in the Queue, it hits my application with the POST block but the request body is coming as empty object.
I have tried the same from the postman, i'm able to receive the data in request body. Only from the Enterprise messaging queue, the data is empty.
In contrast, to verify this, I have used a Express based nodejs application, there i'm able to receive the data from the queue.
What am i missing in the Cloud-SDK based code ?
POST block, looks like this
#Post('ems-events')
receiveEmsEvents(#Body() requestBody: string, #Req() req:Request) {
Logger.log("Event Received with Data:");
Logger.log(requestBody);
Logger.log(req.body);
Logger.log("Log over--");
Logger.log(Object.keys(req));
return {};
}
The SAP Cloud SDK for JavaScript does not offer any support for Enterprise Messaging as of today. The code you're writing here is most likely Nest.js code, which is an independent framework.
That being said, Nest.js does run Express.js under the hood by default. So if you've been able to make it work in Express, you should be able to make it work in Nest.

Api Auto Discovery error in mule logs

Api Auto discovery Error 400... when i deploy my api in cloud(anypoint through runtime manager) it got deployed. but, when i tried to get a response from postman, it says "service not available",i am not able to get a response back from postman.
Is it error 503? In that case the explanation is that the API is not correctly paired to the API in API Manager with client credentials and Autodiscovery. See https://support.mulesoft.com/s/article/API-returns-503-Service-Unavailable-error-to-clients

Google GCM server returns Unauthorized Error 401 while subscribing

I get subscription success in app. But I see Google GCM server returns Unauthorized Error 401 in the server logs.
When I push a message from adapter, I get an authorization failure in server logs. But My adapter gives success response Notification sent to set user.
Can somebody tell me what could be the mistake I would be doing. (can this error also occur when my firewall is restricting this call.)
While subscribing i was getting Reason: 401 unable to authenticate with gcm services. something like this. And While pushing a notification from adapter i was getting reason : unable to authenticate for Api key "ASYI-" with GCM. the error messages may not be exact but the message means just like above
I am getting below error while sending notification
Failed to invoke Google GCM push service.
GCM Service invocation failed (reason: Authentication has failed for sender key starting with 'AIzaSyCk')
also getting below error
GCM push token 'ssdsddsdsdsds' is not added to GCM notification key. GCM Service invocation failed (reason: Returned HTTP/1.1 401 Unauthorized when invoking GCM push service to get the notification key.)
GCM Service invocation failed (reason: Returned HTTP/1.1 401 Unauthorized when invoking GCM push service to get the notification key.)
on the Android studio i see below error :
GCMAPIClient$BackgroundRegistrationHandler.run in GCMAPIClient.java:130 :: Failed to register with GCM using Google Play Services. Error:Error :INVALID_SENDER
Finally it worked for me, two things i did it to work.
Took the GCM.jar file from the sample project and placed it in my project . removed the other gcm dependencies
Created a project in FCM Console (https://console.firebase.google.com/)
and took the google-services.json and placed it in my android studio project under app. Took the web API key from FCM Console and placed it in the mobilefirst app project.(There are two keys now one for app and other for web).
I had to create a new project in the fcm console and new keys..

Mule CXF Web service error handling

This question is on Mule CXF error handling. I have a soap based web service basically this is a validation service that validates an incoming file and reports on any errors in the file. Once validation is unsuccessful i have a catch-exception-strategy which logs the error and sends a email to Prod support team. After validation is unsuccessful i need not call the subsequent steps in the flow. And only the logging and sending an email alert should happen. Shouldn't using a catch-exception-strategy solve the problem ( similar to a try/catch block in Java). But what i notice is the caller is sent a response back and subsequent flow steps are executed
In your catch exception strategy put an asynchronous flow and in that put your logger and smtp to send the mail ... I guess it will solve your problem ...
Since you will be using asynchronous flow response shouldn't be there ... Pls let me know if it solve your issue

How to get details exception from published Web Api

Is there any way to get detail exception & Stack trace from deployed Web Api?
Even if I deployed in Debug mode, do I get detail error traces?
I got bellow message from server API
"message": "Processing of the HTTP request resulted in an exception.
Please see the HTTP response returned by the 'Response' property of
this exception for details."
This happened only in server, same code running perfectly in local machine.
Did you check the content-type for the request that you are performing?
Sometimes this error comes because you don't specify this value, e.g. "application/json" in the headers of the request.
If your scenario is to have a central place to log any exceptions that happen when requests are being processed, then I would suggest to take a look at 5.1 version of Web API (released couple of days back), specifically the Global Error Handling feature.
http://www.asp.net/web-api/overview/releases/whats-new-in-aspnet-web-api-21#global-error
If you go to the above page,you should notice ExceptionLoggerContext which gives you details of the exception.
About Web API versions 5.0 and before:
In these versions there was no really a central place for catching exceptions. ExceptionFilterAttributes caught exceptions for only certain areas of Web API.