Can we accept CSV as a request payload to Apigee? If so, how can we convert the CSV file to JSON.
I want to know if some source system will be able to transfer data in the form of CSV to target system via Apigee, where target system only accepts JSON.
I tried sending csv file to my proxy using postman by passing the file as value in form-data
When I'm trying to extract the content of file using variable request.formparam.fisier the value is coming as null. When I'm trying to extract the value of request.content the vaue is coming as below.
----------------------------774502952050994419113511
Content-Disposition: form-data; name="fisier"; filename="addresses.csv" Content-Type: text/csv John,Doe,120 jefferson st.,Riverside, NJ, 08075 Jack,McGinnis,220 hobo Av.,Phila, PA,09119 "John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075 Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234 ,Blankman,,SomeTown, SD, 00298 "Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123
----------------------------774502952050994419113511--
So, how do I extract this csv content and convert it to JSON?
There's no policy AFAIK in Apigee, but you can use python to convert that. How you want to send via API the csv to Apigee?
That is a "multipart form" payload.
There was a recent question here on community about this. See here.
Summary:
After you extract the "part" that contains the CSV, you can convert that to JSON using either JavaScript or python or whatever makes sense. Because of the possibility that a comma might appear within quotes, parsing is a little tricky, but only a little. If you want a prebuilt thing that parses CSV, you can use this callout.