VSCode REST Client Extension - Loop Request - visual-studio-code

I have the requirement to send nearly the same POST request to a backend system several times - say 50 times.
Is there a way to put the below request into a loop?
###
#POST Gamer
POST {{hostURL}}/api/Gamer
Content-Type: application/json
{
"username": "User-{{$randomInt 3 1000}}",
"characters": [
{
"name": "Superman",
"rpgClass": "Attacker",
"weapon": {
"name": "Flying",
"damage": 100
},
"characterSkill": [
{
"skillId": 1
},
{
"skillId": 2
}
]
}
]
}

Related

How to create multiple entities using a single OData POST to a Business Central Web Service?

I tried to POST an array of objects and, as expected, it isn't that easy. In my case I want to insert multiple Transfer Order Lines in the same request.
// Request Body
[
{
"documentNo": "1002",
"itemNo": "1968-S",
"quantity": 3
},
{
"documentNo": "1002",
"itemNo": "1968-S",
"quantity": 113
}
]
// Response
{
"error": {
"code": "BadRequest",
"message": "Invalid Request Body CorrelationId: a2606676-3f8f-4753-aaee-be91a621f070."
}
}
Is it possible to do what I want without sending a request for every Line entity I want to add?
You need to create a structure like this:
url: api/2.0/$batch
Body:
```lang-json
{
"requests":
[
{
"method": "POST",
"id":"R1",
"url": "companies(id)/APIEntitySetName",
"headers":
{
"content-Type": "application/json"
},
"body":
{}
},
{
another line
}
]
}
```

FAILURE answer from kie-server (using kie-server-showcase and business-central-workbench-showcase)

I am testing business-central with kie-server both running in docker, both are "showcase" versions. I've made project in business-central with "Cow" model (pic) and decision table (pic) for it. Build & Deploy is successful.
After sending json with request body
{
"commands:": [
{
"insert": {
"object": {
"Cow": {
"name": "cow1",
"age": 11
}
},
"out-identifier": "Cow",
"return-object": true
}
},
{
"fire-all-rules": {}
}
]
}
to endpoint
http://localhost:8180/kie-server/services/rest/server/containers/instances/Cow
receiving an error:
{
"type": "FAILURE",
"msg": "Bad request, no commands to be executed - either wrong format or no data",
"result": null
}
Is there anything that I am doing wrong? Why my request doesn't proceed?
I think in your request you need the canonical class name com.axaukraine.Cow, but you are using just the simple name Cow.
{
"commands:": [
{
"insert": {
"object": {
"com.axaukraine.Cow": {
"name": "cow1",
"age": 11
}
},
"out-identifier": "Cow",
"return-object": true
}
},
{
"fire-all-rules": {}
}
]
}

Why I do not receive the attachments in the Facebook Messenger webhook request?

Since yesterday (29/10/2020) i'm having this problem only on one of the pages linked to my app, the others work correctly:
The attached messages that the webhook receives from Facebook do not contain the attachment field.
Only messages with stickers contain the "attachment" field. All others (image, video, audio etc.) No.
What I expect (as facebook documentation) is:
{
"id": "682498302938465",
"time": 1518479195594,
"messaging": [
{
"sender": {
"id": "<PSID>"
},
"recipient": {
"id": "<PAGE_ID>"
},
"timestamp": 1518479195308,
"message": {
"mid": "mid.$cAAJdkrCd2ORnva8ErFhjGm0X_Q_c",
"attachments": [
{
"type": "<image|video|audio|file>",
"payload": {
"url": "<ATTACHMENT_URL>"
}
}
]
}
}
]
}
but I only receive:
{
"object": "page",
"entry": [
{
"id": "119320008135788",
"time": 1604051633128,
"messaging": [
{
"sender": {
"id": "XXXXXX"
},
"recipient": {
"id": "XXXXXX"
},
"timestamp": 1604051632953,
"message": {
"mid": "m_7DRP...."
}
}
]
}
]
}
This only happens on one page from 29/10/2020
Does anyone have the same problem / know why it happens?
The Facebook support team has confirmed my problem, and is investigating.
I am now solving using the graph api to get the desired message information using the mid
GET /v8.0/{message-id} HTTP/1.1
Host: graph.facebook.com
https://developers.facebook.com/docs/graph-api/reference/v8.0/message
Ex.
GET
https://graph.facebook.com/v8.0/' + mid + '?fields=message%2Cfrom%2Csticker%2Ctags%2Cid%2Cattachments.limit(10)%7Bid%2Cimage_data%2Cmime_type%2Cname%2Cfile_url%2Cvideo_data%7D&access_token=XXXXXX

Fetching multiple event details in Office 365

I need to fetch information related to eventId from office 365 for multiple events.
Is there a way I can get that info in a single REST call?
I want specific events only (based on eventId's only)
A batch request may be what you are looking for.
See json Batching Documentation for more information
Keep in mind that batching is currently limited to 20 requests per message (known issues)
Example:
You will need to send a POST Message to the batch endpoint
https://graph.microsoft.com/v1.0/$batch
inside the body you will need to include your requests:
Note: do not include the server url (https://graph.microsoft.com/v1.0/) in the url property or the request will fail with "BadRequest - Invalid request Uri".
Request-Body:
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/me/calendarview?startdatetime=2018-03-01T18:31:34.206Z&enddatetime=2018-03-12T18:31:34.206Z"
},
{
"id": "2",
"method": "GET",
"url": "/me/events/{someEventId}"
},
]
}
When the server has processed all requests an response array containing the results will be sent back:
Server-Response:
{
"responses": [
{
"id": "2",
"status": 200,
"headers": {
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8",
"ETag": "W/\"Z+ICSvkiAfZX7XWQAZ6IH==\""
},
"body": {
// the event object
}
},
{
"id": "1",
"status": 200,
"headers": {
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('aUserID')/calendarView",
"value": [
// list of found event-objects
]
}
}
]
}

Sabre api revalidate service unavailable?

I am trying to use the REST Revalidate Itinerary service provided by Sabre.If you have access to the sabre developer site, you can find the details here:
https://developer.sabre.com/docs/read/rest_apis/air/search/revalidate_itinerary
I am posting to api.sabre.com/v3.3.0/shop/flights/revalidate as instructed, but I am getting a 404 back with the message that "No service exists" at that URL.
Has anyone been able to get this to work, or does anyone know the correct URL?
Updated with the raw response, obtained using Fiddler:
HTTP/1.1 404 Not Found
date: Wed, 21 Feb 2018 17:05:39 GMT
EnvType: production
message-id: EogQto
singularityheader: appId=1448*ctrlguid=1516860998*acctguid=9e6c885b-de5c-4175-ac13-773e8d4b7ab2*ts=1519232739414*btid=16580*guid=5daa09fd-ca10-4c8b-b35c-968a410d211e*exitguid=1|1*unresolvedexitid=49225*tcop=1:2058128*cidfrom=171608*etypeorder=JMS*esubtype=JMS*cidto={[UNRESOLVED][49225]}*tcop=1:2058128
x-provider-instance-id: raf-darhlp010-8080
Content-Type: application/json;charset=UTF-8
Content-Length: 255
Server: Sabre Gateway
{"status":"Complete","reportingSystem":"RAF","timeStamp":"2018-02-21T17:05:39+00:00","type":"Application","errorCode":"WARN.RAF.APPLICATION","instance":"raf-darhlp010-8080","message":"No service exists for: /cto-darwin-raf/v3.4.0/shop/flights/revalidate"}
Here is my payload in full:
POST https: //api.havail.sabre.com/v3.4.0/shop/flights/revalidate?mode=live HTTP/1.1
Authorization: Bearer T1RLAQJ940LxYe01yXkBtjZ6g6PEJkjPfxDiW51CX1eYL52BV7ZR+vuQAACw70cYo2xd9slV8ZA8cpJFXg+4qGrxxg83PFKleE3Vm7AHTbrztkg3aHccOVLazItRcJmtR/Ohz96mz +em96HYv2n8SVBgdKTvcN1rwhBXrFsmGKY8E+LUK2wBPSQVz8kGmPW89G//EPp1igTJaaWZrJFxoq40G8SCS0HEyt3RTMNmVLtv7q0a+xuQWYJyGKpxSujRIeJzajN86YiJ7+Eck8rpyFnVOyIlKnO5fiX6C6E*
Content-Type: application/json; charset=utf-8
Host: api.havail.sabre.com
Content-Length: 1204
Expect: 100-continue
{
"OTA_AirLowFareSearchRQ": {
"POS": {
"Source": [
{
"RequestorID": {
"CompanyName": {
"Code": "TN"
},
"Type": "1",
"ID": "1"
},
"PseudoCityCode": "C94H"
}
]
},
"OriginDestinationInformation": [
{
"DepartureDateTime": "2018-03-23T08:50:00",
"OriginLocation": {
"LocationCode": "LHR"
},
"DestinationLocation": {
"LocationCode": "JFK"
},
"TPA_Extensions": {
"Flight": [
{
"OriginLocation": {
"LocationCode": "LHR"
},
"DestinationLocation": {
"LocationCode": "JFK"
},
"Airline": {
"Operating": "VS",
"Marketing": "DL"
},
"ClassOfService": "B",
"Number": 4370.0,
"DepartureDateTime": "2018-03-23T08:50:00",
"ArrivalDateTime": "2018-03-23T13:00:00",
"Type": "A"
}
]
},
"RPH": "1"
},
{
"DepartureDateTime": "2018-03-24T19:30:00",
"OriginLocation": {
"LocationCode": "JFK"
},
"DestinationLocation": {
"LocationCode": "LHR"
},
"TPA_Extensions": {
"Flight": [
{
"OriginLocation": {
"LocationCode": "JFK"
},
"DestinationLocation": {
"LocationCode": "LHR"
},
"Airline": {
"Operating": "VS",
"Marketing": "DL"
},
"ClassOfService": "B",
"Number": 4373.0,
"DepartureDateTime": "2018-03-24T19:30:00",
"ArrivalDateTime": "2018-03-25T07:30:00",
"Type": "A"
}
]
},
"RPH": "2"
}
],
"TravelerInfoSummary": {
"SeatsRequested": [
1
],
"AirTravelerAvail": [
{
"PassengerTypeQuantity": [
{
"Code": "ADT",
"Quantity": 1
}
]
}
],
"PriceRequestInformation": {
"TPA_Extensions": {}
}
}
}
}
You should probably not start using the endpoint you are using. According to the https://developer.sabre.com/resources/api_versioning it gets switched to https://api.havail.sabre.com by mid of the year. I guess you already use https?
Besides that it works for me when taking the sample payload and adjusting it for real data. Can you provide your header/payload?
Turns out it didn't like the querystring '?mode=live'. If I remove that, I get a response. We use that string in all our other REST requests to shop/flights/ but looks like it's not valid in this circumstance.
Also, thanks to Thomas for his help