Retrieve Repsonse Code from the Request Object - symfony

I need to create a middleware app that provides an api and consumes two apis. I am currently taking data from API A and creating data to send to API B via the HttpFoundation Request class. However, before I take the response from API B and send it back to API A; I would like to make sure that the HTTP Status Code is 200.
I don't see the ability to check for the status code when using the Request class.

Related

Automatically adding custom header to message based on request scope

RequestClients in my ApiGateway are injected (using default MS DI) in HTTP request handlers (in those handlers I have access to current request scope). What I want is to automatically, for each RequestClient, to add custom message header where I could put some data from request scope. Use case is to take JWT from request and add it to message as custom header. Then on consumer side I need, for each received request, check that custom header, verify JWT, and add some data from it to consumed request scope so I could access for example IUserContext or something like that. I want to avoid manually adding jwt to message contract for example.
How I can configure MassTransit on Client and Consumer side to achieve what I want? I already read docs about middleware and pipes and observers but still I can't figure it out...
Using RabbitMQ transport.
So, this is pretty complicated to put into a post, so I created a complete sample that shows how to use MassTransit Scoped Filters.
In this sample, an action filter is registered with the controllers to automatically extract the Token header and store it so that it can be used when publishing or sending messages from a controller. The MassTransit filters are configured on the bus, so they're available to all receive endpoints.

Third party to PeopleSoft SSO integration

I have to write sign on peoplecode to make a service call by passing token (sent from third party) to API and get the responce (if token is valid responce will have username) in json format to create a PS_TOKEN.
I am fresher to peoplecode. How can I run HTTP POST request by passing token and get the response using Peoplecode?
You would create a synchronous service operation in the Integration Broker. The Integration Broker works best if you are sending XML or JSON. If this is just a regular HTTP POST with fields then it can cause some issues with the Integration Broker. I had a similar case and could not get the basic HTTP Post to work but instead ended up using HTTP POST multipart/form-data and was able to get that to work.
Steps I had to do to make this work.
Create a Message (document based or rowset based are both possible)
Create Service Operation and related objects
Create Transform App Engine to convert the Message to a HTTP POST multipart/form-data
Create a routing and modify the connector properties to send the content type of multipart/form-data. Also call the Transform app engine as part of the routing.
The issue with a application/x-www-form-urlencoded POST is that it seems PeopleSoft does another url encoding after the Transform, which is the last time you can touch the output with code. This final url encoding was encoding the = sign in the form post which made the format invalid.
Your other option would be to write this is Java and call the Java class from within PeopleSoft (or mix the Java objects in with PeopleCode). If you choose to go this way then the App Server needs to have connectivity to your authentication server. My only experience with this is I had a client that used this approach and had issues under heavy load. It was never determined the cause of the performance issue, they switched to LDAP instead to resolve the issue.

how do i resend a request after processing it inside my apigee endpoint

I have a endpoint called get user data which accepts a token
I need to read this token in my apigee and send it to tokenVarificationExtUrl
which gets back to me with
a) valid 200
b) userid attached with that token
now what i have to do is i need to read the response header and then conditionally check it for 200 success and then extract the userid from the response.
Once its extracted i need to attach it with another request; which i need to send to getUserData external url
which will get back to me with required user details.
I am successful of extracting data and doing conditional check. I am seeking help for
how do i send another request to getUserData external url.
You need to use a few policies in your proxy.
For example
For checking a header and throwing an error, you may want to use rasie fault policy conditionally
For making an API call to external end-point you can use service callout policy or a standard target
For exrtacting response data from json or xml payload you can use json path of xpath policies
and so on.
I suppose you may want to take a look at a few sample proxies with these functions to be able to design your own.
Check this link out. http://apigee.com/docs/content/using-sample-api-proxies

How can I add custom JSON parameter in JIRA webhook?

I have a web-servise which listens to the JSON requests from different data sources. I want to identify data source by special parameter data-source. My question is how I can add field "data-source": "jira" to the webhook JSON body?
EDIT
For now my solution is to add to my webhook uri http://127.0.0.1:8080/DC data source parameter like this: http://127.0.0.1:8080/DC?data-source=jira, then check data source type and if it is equal to jira send request JSON body to method jiraJsonParser().
But I'm not sure if it is the best solution, isn't it?
I had a similar need, and solved the problem by creating a REST API with flask that acts as an aggregator/translator to accept requests from multiple tools, format the request as needed, and pass it on to it's intended target. For example, I have a Jira 'build request' ticket that sends a POST request via webhook to my API upon ticket creation. The API accepts the request, formats it as needed, fwd's the request on to Jenkins to run a build. As each part of the build runs, Jenkins sends requests back to the API, which get formatted as needed, and the original Jira ticket gets updated with the details/status of the build.
Here's a good article on building a REST API with flask - http://blog.luisrei.com/articles/flaskrest.html

(REST ) Client - set the javax.servlet.http.HttpServletRequest into request How to?

A lot of web applications must be used the specified REST service. This REST service uses currently the informations only from javax.servlet.http.HttpServletRequest. This HttpServletRequest may be contain the specific cookie and other parameters.
I'm try to use the (REST) client API form JERSEY to realize a client, that will build the REST requests. This client will be called within custom web filter, that will be registered by web.xml of each web application.
Currently i have the following problem: i'm don't know, howto transmitt the HttpServletRequest during call of the REST Service....
Thx for your help....
So if I understand correctly, you want receive a request in any of the web applications, and then you want to forward this request to the REST web service?
If so, you will need to serialize the request to make it transportable. You could also create a class that is able to hold the data that you need from the javax.servlet.http.HttpServletRequest and then serialize it into XML or JSON.
If you have the request in a more transportable format, you can pass it to your REST service via a #HeaderParam or as the request body (I would prefer the latter).

Resources