Created a BPMN2 custom task flow that validates some data. A REST API was created with Apache HTTPEntity to complete the functionality.
The class extended KogitoWorkItemHandler and implemented the executeWorkItem method.
But even in case of validation failure i get a 2xx response.
Is it possible to make an error or even a customised response as part of a custom task flow?
App was created using Quarkus. A simple custom task in Kogito.
Related
I am using spring cloud gateway Hoxton.M1 release to implement an API gateway. I have the following two spring boot apps -
Client <-> Router App <-> Wrapper App <-> Downstream application
Router App - This application has spring cloud gateway. All routes in application.yml point to a common REST controller end point in Wrapper application by passing a request header attribute "apiendpointid" to diff b/w diff api calls. Below is a sample route entry
- id: milestone
uri: http://localhost:5001
predicates:
- Path=/track/milestone
- Method=POST
filters:
- RewritePath=/track/milestone,/gateway/api/internal/process
- AddRequestHeader=apiendpointid,retailmilestone
- AddRequestHeader=appid,retail
- SecureHeaders
Wrapper App - This is a spring boot application which has Rest controller. Controller method does the following -
Identify JSON schema file basis the "apiendpointid" request
header attribute and apply JSON schema validation. Reject request in
case of schema validation failures by return 400 response to router
app.
Identity the freemarker request transformation file basis the "apiendpointid" request header attribute and transform incoming request to downstream expected format.
Send request to downstream.
Transform response from downstream to expected format again using freemarker response template.
Send response back to router app.
This works fine but there is an extra http "hop" from router to wrapper. We have not yet gone live; so not very sure if it will be a performance concern.
Currently wrapper is not built in a reactive way. Also team does not have much expertise in reactive programming. Are there any production implementations built this way (i.e. having this extra wrapper layer/app in the middle) or is it better to integrate all wrapper functionalities into router app itself? If yes, could you please direct me to some examples where request/response transformations/schema validations are being done in spring cloud gateway itself?
I don't mind if you use an example from another API that is not Adobe Analytics'. I just need to know the pattern that I have to follow in order to succesfully convert a Postman request into a NiFi request.
After successfully creating requests to pull reports from Adobe Analytics via Postman, I´m having difficulties to migrate these Postman requests to NiFi. I haven´t been able to find concrete use cases that explicity explain how to do this kind of task step-by-step.
I'm trying to build a backend on top of NiFi to handle multiple data extracts from Adobe Analytics in an efficient and robust way. That is instead of having to create all required scripts by myself. Yet, there is more documentation about REST APIs and Postman cases than there is about REST APIs and NiFi cases.
In the screenshot below we can see how the Postman request looks like. It takes 3 headers and 1 temporary header that includes the authorization value (Bearer token). This temporary header is generated automatically after filling in the OAuth 2.0 authorization form in the Authorization tab, as shown here.
Then, we have the body of the request. This json text is generated automatically by debugging Adobe Analytics' workspaces as shown here.
I'd like to know the following in a step-by-step manner with screenshots if possible:
Which processor(s) should I use in NiFi to obtain a similar response as the one I got in Postman?
Which properties should I add/remove from the processor to make this work?
How should I name these properties?
Is there a default property whose value/name I should modify?
As you can see, the question mainly refers to properties setup in NiFi, as well as Processor selection. I already tried to configure some processors but I don't seem to get the correct properties setup, or maybe I'm selecting the wrong processors.
I'm using NiFi v1.6.0 and Postman v7.8.0
This is most likely an easy task for users already familiar with NiFi and API requests, but it has proven challenging to me. Hopefully this will help other users looking to build more robust pipelines by using NiFi instead of doing it manually.
Thanks.
It only takes 3 NiFi processors to replicate a REST API request that works in Postman. In this solution we use a request that contains a nested JSON request. The advantage of this simple approach is that it reduces the amount of configuration required to obtain a successful response from the API. That is, even if you are using a complex JSON request. In this case the body of the JSON request is passed through the GenerateFlowFile processor, without the need of any other processor to parse/format the request.
Step #1. Create a processor called GenerateFlowFile. The only property that you will have to modify is the Custom Text. Paste in there your whole JSON request just as it was in Postman. In this case I'm using the very same JSON shown in the question above. It's a good idea to setup Yield Duration to 10 seconds or more.
Step #2. Create a processor called InvokeHTTP. Then modify the 6 properties shown in the screenshots below. Use the same Authorization details you've used in Postman. Make sure to copy the Bearer token from Postman after it has been tested. Also, don't forget to setup the HTTP Method, Remote URL and Content-Type as well.
Step #3. Finally, add a couple of LogAttribute processors to store the output of InvokeHTTP. One of these LogAttribute processors should store successful responses. The other one can be used for Failure, Original, Retry and No-Retry. Or you can create LogAttribute for each of these outputs.
Step #4. Now, connect the processors and Start your data flow! You should start seeing data populate the Successful LogAttribute. Then you can use the Data Provenance option to review the incoming data and confirm that this is exactly the same result you previously obtained from Postman.
Note: This is a simple, straightforward, "for starters" solution to replicate a Postman API request using a nested static JSON. There are more solutions in StackOverflow that tackle more complex cases, like dynamic JSON. Here's a list of some other posts:
nifi invokehttp post complex json
In NiFi processor 'InvokeHTTP' where do you write body of POST request?
Configuring HTTP POST request from Nifi
I'm writing a HATEOAS-driven REST API and it would be convenient to return responses from some actions with links to other resources.
As the REST API is currently implemented following a monolithic architecture, and in order to not only reduce redundancies but also simplify the job of migrating some parts to microservices, it would be nice if an action could send responses based on the URL that was routed to it.
So, does anyone know if ASP.NET core 2.1 offers any way to access the full URL that's routed to an action when a request is routed to said action?
I have followed the steps of creating a helloblockchain workbench application for request and responder type.I have got the all contracts details using Azure Blockchain Workbench REST API using "/api/v1/contracts/{{contractId}}".But i unable to post the message or actions using the api "api/v1/contracts/{{contractid}}/actions".So please some one help me regarding this.
If you are trying to create a new contract, you need to use the constructor as the function ID.
And the API that you are using"api/v1/contracts/{{contractid}}/actions" is for creating a response to an already existing contract and it can only be performed by passing the credentials of a Responder in the Authentication bearer.
I'm attempting to use SoapUI (5.0.0 beta) to test a RESTful web service which issues asynchronous responses to a supplied Callback URL.
So far, I am able to invoke the service and confirm the initial synchronous response received. I have also created a 'REST MockService' that issues an appropriate response to the callback received from the server, and I supply the endpoint for this as the Callback URL in the initial request.
What I am now struggling with is creating a test case that ties the two together such that I can 'expect' the asynchronous callback before proceeding to another step in my test case. I tried adding a 'Mock Response' Test Step to my test case following the initial request. However, this just yields an unhelpful 'Missing SOAP Operations to Mock in Project' error message. I took a brief look at the SoapUI source for this error message and discovered the method returning the error is first checking if I am using a WSDL interface. Why I would be doing so with a REST project is beyond me, but there you have it!
Appreciate any guidance on how to proceed!
Having logged a query on the SoapUI Community Board, it seems there is currently not a good mechanism for achieving this, but my query has prompted an enhancement request at least!
http://forum.soapui.org/viewtopic.php?f=5&t=23697