343
Views
20
Comments
Consume api with input as .csv file
Question

Hey,

Can anyone please help me consuming an external api with with input as .csv file .
I have created the csv file using the forge component (CSVUtil). I am not sure how to pass it to the service. 

Thanks,
Angha

2016-04-22 00-29-45
Nuno Reis
 
MVP

Hi Anagha.

Have you checked this one-page help to call web services and APIs?

I guess you simply need to send the CSV to the binary/text input field.


2021-01-04 08-13-48
Toto
 
MVP
2020-02-13 05-29-21
Anagha Chikate

Hi Toto,

Yes the external API does use Content-Type as Multipart/Form-Data. I also downloaded the component you just shared.
Do we have any sample for this particular forge component? It would be great help.


Thanks,
Anagha


2021-01-04 08-13-48
Toto
 
MVP

Yes, the plugin is a little bit tricky.

I'm sorry I cannot provide you with oml (my Webservice is private use).


First, create local variable using the structure from the plugin (Part). You need Part variable and List of Part variable (see image below)


This is how to call the web service


You need to assign the part variable with component that you need (here in my example is image)

Then append it to list of part variable


Put the MultipartFormDataCreate

Boundary = hardcoded 

SyntaxEditor Code Snippet

----WebKitFormBoundary7MA4YWxkTrZu0gW



Then on the web service consume

with content-type hardcoded

SyntaxEditor Code Snippet

"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
2020-02-13 05-29-21
Anagha Chikate

Thanks For the reply Toto.

I used the component and what I got the response after converting it from binary to text is the below.

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="File"
Content-Type: multipart/form-data

Id,FName,LName,Email
1, Anagha, Chikate, achikate@xyz.com
2,Paree,Bansal,pbansal@xyz.com

------WebKitFormBoundary7MA4YWxkTrZu0gW--


When I hit the service with this file in request text, its giving me 400 error.

Am I missing on something?


Thanks,

Anagha 

2021-01-04 08-13-48
Toto
 
MVP

Anagha Chikate wrote:

Thanks For the reply Toto.

I used the component and what I got the response after converting it from binary to text is the below.

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="File"
Content-Type: multipart/form-data

Id,FName,LName,Email
1, Anagha, Chikate, achikate@xyz.com
2,Paree,Bansal,pbansal@xyz.com

------WebKitFormBoundary7MA4YWxkTrZu0gW--


When I hit the service with this file in request text, its giving me 400 error.

Am I missing on something?


Thanks,

Anagha 


Id,FName,LName,Email
1, Anagha, Chikate, achikate@xyz.com
2,Paree,Bansal,pbansal@xyz.com

is this the file content or there is 3 parameter on webservice body ?

can you provide postman screenshot about your webservice (please blur the address, I just need to see the parameter)


2020-02-13 05-29-21
Anagha Chikate

Toto wrote:

Anagha Chikate wrote:

Thanks For the reply Toto.

I used the component and what I got the response after converting it from binary to text is the below.

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="File"
Content-Type: multipart/form-data

Id,FName,LName,Email
1, Anagha, Chikate, achikate@xyz.com
2,Paree,Bansal,pbansal@xyz.com

------WebKitFormBoundary7MA4YWxkTrZu0gW--


When I hit the service with this file in request text, its giving me 400 error.

Am I missing on something?


Thanks,

Anagha 


Id,FName,LName,Email
1, Anagha, Chikate, achikate@xyz.com
2,Paree,Bansal,pbansal@xyz.com

is this the file content or there is 3 parameter on webservice body ?

can you provide postman screenshot about your webservice (please blur the address, I just need to see the parameter)


Hey,

These are not the parameters, this is my csv content passed in body.


2021-01-04 08-13-48
Toto
 
MVP

If you cannot provide postman screenshot, can you provide the action ?

2020-02-13 05-29-21
Anagha Chikate

hey Toto,



PostEmployee is the external rest service that I am calling, which is Post type with request set to binary type.

2020-02-13 05-29-21
Anagha Chikate

Hey, 

Find the attached test oml. 

Thanks,
Anagha

RolePoint_POC.oml
2020-02-13 05-29-21
Anagha Chikate

Anagha Chikate wrote:

Hey, 

Find the attached test oml. 

Thanks,
Anagha


Uploaded in here :-D

2021-01-04 08-13-48
Toto
 
MVP

Hi Anagha,


In the PostEmployee, contenttype should filled with 

"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"

In my case, this is the problems

2020-02-13 05-29-21
Anagha Chikate

Hi,

Changing the content type didnt help.

Please find the attached test oml.


Thanks,

Anagha.

RolePoint_POC.oml
2021-01-04 08-13-48
Toto
 
MVP

Hi Anagha,


I'm waiting for the upload complete :D It seems there is a slowdown in the forum.

2020-02-13 05-29-21
Anagha Chikate

Yes I see that, I uploaded it twice. Please see the previous file in conversion. 

2021-01-04 08-13-48
Toto
 
MVP

Still not updated, still uploading

2021-01-04 08-13-48
Toto
 
MVP

Ups, my mistake sorry

Let me check it.


And this is the translation from your code to the postman

is this correct ?

key : employees.csv

filename and content : employees.csv


This will translate as key

2020-02-13 05-29-21
Anagha Chikate

I guess that is correct. 

I am hitting service A (that I have exposed) and in that service I am consuming service B (PostEmployee in the test oml), to which I want to send the employee.csv.


2021-01-04 08-13-48
Toto
 
MVP

Anagha Chikate wrote:

I guess that is correct. 

I am hitting service A (that I have exposed) and in that service I am consuming service B (PostEmployee in the test oml), to which I want to send the employee.csv.



But its very uncommon that key is filename.

You said you expose the API? Using outsystems?

Usually expose using outsystems resulted in json type (raw json in postman)

2020-09-21 11-35-56
Sachin Waghmare

Hello,

I am consuming a REST API where have to upload a .csv file with content type as "Multipart/form-data". We are using forge component as below and getting error as highlighted in yellow color. 

https://www.outsystems.com/forge/component-overview/4026/multipart-form-data

Any help for this issue resolution will be appreciated.

Thanks & Regards,

Sachin


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.