I have a scenario where the http response from a different web service can contain mixed results. For e.g
Sample Request : POST /fetchdata
{
"empIdSet": [
{
"empId": 123,
"empId": 456
}
]
}
Sample Response:
{
"empDetailsResponse": [
{
"id": 123,
"fname": "Tom",
"lname": "Smith"
"status": "Active"
},
{
"id": 456,
"status": "NOT_FOUND"
]
}
The response looks like Mono<EmpDataResponse> and the EmpDataResponse contains List<EmpDetailsResponse>
The method looks like:
Mono<EmpDataResponse> fetchData(EmpDataRequest empDataRequest)
I have ResponseHandler which is interested in !NOT_FOUND list and the ErrorResponseHandler handles cases whose status is NOT_FOUND.
Is there a way i can process my above to handlers once i get the response back from the webclient service class?
Thanks
Related
I am getting many responses via GET http request but I only want to fetch the ID of first student which I got in response how to do it in Rest Assured.
[
{
"id": 14114,
"name": "Pragyanshii",
},
{
"id": 14119,
"name": "ankit",
},
{
"id": 14122,
"name": "varun",
}
]
I want to fetch id: 14114
This is one way to achieve your goal.
Response response = ...;
int id = response.jsonPath().get("[0].id");
System.out.println(id); //14114
I can’t understand how to create the http body of the Modify User Account api:
PATCH
https://api.appstoreconnect.apple.com/v1/users/{id}
In particular the:
[UserUpdateRequest.Data.Relationships.VisibleApps.Data]
What are the required id and type properties of Data object? Could somebody provide a code or postman example of a request ?
This is the url of the topic:
Appstoreconnect Api - Update User
The PATCH request should look like this:
PATCH /v1/users/XXX
{
"data": {
"type": "users",
"id": "XXX",
"attributes": {
"allAppsVisible": false
},
"relationships": {
"visibleApps": {
"data": [
{"type": "apps", "id": "AAA"},
{"type": "apps", "id": "BBB"}
]
}
}
}
}
Where AAA and BBB are Apple IDs of your apps. You can find these on the App Information page, or in response to the /v1/apps API calls.
I have a logic app which is triggered by new messages on a Service Bus subscription. The message is a json object, like the following:
{
"PublisherName": "XXX",
"PublisherKey": "XXX",
"Identifier": "XXX",
"Value": {
// ...
}
}
How can I do an http request, using the publisher key as a header, the identifier as a query parameter, and the value as the body?
Typically, your service bus message from your subscription will be base64 encoded.
Try the following in code view:
"queries": {
"Identifier": "#json(base64ToString(triggerBody()?['ContentData'])).Identifier"
}
"headers": {
"PublisherKey": "#json(base64ToString(triggerBody()?['ContentData'])).PublisherKey"
}
Try the following
"httpAction": {
"type": "Http",
"inputs": {
"body": "#triggerBody().Value",
"method": "POST",
"uri": "http://endpoint.com",
"queries": {
"Identifier": "#triggerBody().Identifier"
}
"headers": {
"PublisherKey": "#triggerBody().PublisherKey"
}
}
}
In GraphQL response normally looks like followings.
{
"data": [{
"id": 1,
"username": "Jon Snow",
"email": "crow#northofthew.all",
"age": 20
}, {
"id": 2,
"username": "Tyrion Lannister",
"email": "drunk#i.mp",
"age": 34
}, {
"id": 3,
"username": "Sansa Stark",
"email": "redhead#why.me",
"age": 17
}]
}
Is it possible to add meta data to your response such as pagination like this.
{
"pagination": {
"total": 14,
"count": 230,
},
"data": [{
"id": 1,
"username": "Jon Snow",
"email": "crow#northofthew.all",
"age": 20
}, {
"id": 2,
"username": "Tyrion Lannister",
"email": "drunk#i.mp",
"age": 34
}]
}
I'm using express-graphql and currently put those pagination to custom response header, which is fine but it can be better. Since GraphQL response is already wrapped with "data", it is not very strange to add more "data" to its response.
Reenforcing what #CommonsWare already stated, according to the specification that would a be an invalid GraphQL response. Regarding pagination, Relay has its own pagination approach called connections, but indeed, several other approaches are possible and even more suitable in some situtations (connections aren't a silver bullet).
I want to augment what was already said by adding that the hierarchical nature of GraphQL incites related data to be at the same level. An example is worth a thousands words, so here it goes:
query Q {
pagination_info { # what is this info related to? completely unclear
total
count
}
user {
friends {
id
}
}
}
Instead...
query Q {
user {
friends {
pagination_info { # fairly obvious that this is related to friends
total
count
}
friend {
id
}
}
}
}
When using the API to place an order for a VIP, it is failing with a non intuitive error message. Please see the following REST API call JSON and the ensuing error:
JSON:
{
"loadBalancer": {
"name": "lbName_TEST",
"id" : 123,
"type": "HTTP",
"sourcePort": 80,
"virtualIpAddress": "123.123.123.123"
}
}
REST API URL USED:
https://user.name:longid4235234532#api.softlayer.com/rest/v3/SoftLayer_Network_Application_Delivery_Controller/15293/createLiveLoadBalancer.json
{
"error": "Invalid port supplied.",
"code": "SoftLayer_Exception_Public"
}
The question that arises is this. We are trying to script the ordering of a VPX Netscaler and the addition of all related configurations to the created VPX, are we doing something out of order?
Related to create the loadBalancer the JSON is wrong, try this JSON:
{
"parameters": [
{
"name": "lbName_TEST",
"type": "HTTP",
"sourcePort": 80,
"virtualIpAddress": "123.123.123.123",
"loadBalancingMethod": "pi"
}
]
}
Regards
To order a device or service, you need to use the SoftLayer_Product_Order::placeOrder method. here an example to order a NetScaler
URL: https://api.softlayer.com/rest/v3/SoftLayer_Product_Order/placeOrder
Method: POST
PAYLOAD: {
"parameters": [
{
"packageId": 192,
"location": 265592,
"prices": [
{
"id": 22315,
"complexType": "SoftLayer_Product_Item_Price"
},
{
"id": 17238,
"complexType": "SoftLayer_Product_Item_Price"
}
],
"complexType": "SoftLayer_Container_Product_Order_Network_Application_Delivery_Controller"
}
]
}
The price 22315 is for a "Citrix NetScaler VPX 10.1 10Mbps Standard" and the 17238 is for "2 Static Public IP Addresses"
To get all the prices use the http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItems method