bots-edi / bots

Bots EDI Translator
GNU General Public License v3.0
136 stars 84 forks source link

RESTful API support #51

Open LuisJIA opened 5 years ago

LuisJIA commented 5 years ago

I need to retrieve a JSON document from a RESTful API as a file. I then need to translate the document and make it a new JSON file. I then need to post it to another RESTful API.

At the moment I use bots to make XML documents from EDI X12 documents. Then a external receiver picks up the XML documents to import to another system.

I was hoping to use bots for API document movements. Any hints of how to add this feature? thanks.

hgooijen commented 5 years ago

Then you have to create a communicationscript for a http(s) channel.

I added a incoming and outgoing communicationscript as reference. depenging on what api you're using the "outResponse" valua van be different. For example, if the api uses headers you can change it to:

                headers = {'Content-Type':'application/json','Accept':'application/json'}
                outResponse = self.session.post(URLremotefile, headers=headers, data=content)

You can also use 2 post requests, one to first pick up a API-token, which can be used in the second post request to send/receive the data.

If you're sending something to an API (outgoing communicationscript) and want to process it's response, look into "ta_resp". there you can set the message parameters. Then add an extra route sequence and proces that message as you would like.

Good luck :)

API_Incoming_Communicationscript.txt API_Outgoing_Communicationscript.txt