Can I send multiple records in a web service integration? Follow

Avatar
Samantha Petro

Question

 I want to send multiple records at once over a web service integration. Is that possible?

Answer

Short answer: when using GET, no. When using POST, yes.

Using GET

GET integrations do not allow for more than one record due to how data is being sent. The information is pieced together then sent to BarTender as part of the URL as shown here in Insomnia:

web_service.png

This means only one record can be sent at a time since only one record fits into the URL.

Using POST

POST integrations do not send information over the URL so this allows you to send as many records as you want in one go:

web_service2.png

When using the %Response% variable as a response, each record may show up as its own print job depending upon how the data is separated. For my example, I'm sending the printer information in the POST, so each record is a considered separate print job.

For more information about response patterns, see What is in a web service integration response by default? 

7 comments

0
Avatar
Kenneth Fox
Comment actions Permalink

I would like to know if there is a way to actually send multiple records via POST as one request and get it to execute as a single print job.  My data would preferably be formatted as JSON with a header record containing the label file and printer.  That would be followed by multiple product records each with it's own data field values and quantity.

0
Avatar
Samantha Petro
Moderator
Comment actions Permalink

You will need BarTender 2021 as 2019 and earlier does not support using a JSON structure as a database (you have to do all sorts of data processing to transform the data into a CSV or equivalent database). You could try setting up a JSON database and using it in an integration much like in this example with XML https://support.seagullscientific.com/hc/en-us/articles/360044730333-Creating-an-XML-integration . This is a file integration, but at the end of the day, data is still data, and that's all the integration cares about as long as it gets there. You could send the data via file or POST.

If you need help building it, contact Professional Services.

1
Avatar
Dirk-Jan Kooij
Comment actions Permalink

Wouldn't is be much more logical to send a JSON like

{
"printername": "testprinter",
"layout": "sscc.btw",
"items": [{
"SSCC": 1234
},
{
"SSCC": 1235
}
]
}
This should lead to a single-print-job (similar to a file-integration), where you get 1 response.
Is this supported?
0
Avatar
Lorenz Pfyl
Comment actions Permalink

Any news on this topic? We also wait for a solution to send several labels in one request by JSON.

0
Avatar
Samantha Petro
Moderator
Comment actions Permalink

You can send multiple records in one JSON if you use JSON as your database in a label. Note that this only works in BarTender 2021 and later.

Essentially you would do the following

  • configure your label to use a JSON-type database, and make that database a sample JSON file that has the same name-value pairs that you'll be sending in the integration
  • use a Print Document command on your web service integration and make sure to override the database to use EventData as its database
  • Send JSON to the listening integration in a POST
0
Avatar
Lorenz Pfyl
Comment actions Permalink

Do you have a sample of a JSON request or a link to a documentation with a sample?

0
Avatar
Mohamed Gamal
Comment actions Permalink

Hi, Can you share a sample how the BTW should be designed and the correct JsonCode syntax.

Please sign in to leave a comment.