cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve a CSV file by API: only first row is retrieved

Pcu318
Explorer
0 Kudos

Hi experts,

I'm trying to retrieve a csv file from a rest API, but when the body is retrieved I have only the first row of csv. Below how I do, where is the mistake? (with Postman is ok)

Many thanks in advance.

example of csv

"sf__Id","sf__Error",Cod_cliente__c,Name,Partita_iva__c,Indirizzo__CountryCode__s,Indirizzo__StateCode__s,Indirizzo__City__s,Indirizzo__PostalCode__s,Indirizzo__Street__s

0008000141,COMPANY 1 S.P.A.,IT0201124,IT,PD,Padova,35020,"VIA test, 2"

cl_http_client=>create_by_url

go_http_client->request->set_header_fields( fields = lt_header_fields ).

go_http_client->request->set_method( if_http_request=>co_request_method_get ).

go_http_client->send

go_http_client->receive

gv_response = go_http_client->response->get_cdata( ).

here I have only the first row

PaolaCuoghi_0-1709476611384.png

 

PaolaCuoghi_1-1709476611387.png

 

Sandra_Rossi
Active Contributor
0 Kudos
If it "doesn't work" in ABAP, it's because the request is different. Take the full Postman request and do the same in ABAP. If you don't know, post the Postman request here.
View Entire Topic
Former Member
0 Kudos

8000 char is a too long string and if you try to break down to 132 chars each there will be around 60 columns for you to store data in.

If you are OK with having 60 columns then you can have a check in each column on length and use substring function to populate that.

Column 1 - ifthenelse(length(source_column) > 132, SUBSTR(source_column,1,132), SUBSTR(source_column, 1, length(source_column)) )

Column 2 - ifthenelse(length(source_column) > 132*2, SUBSTR(source_column,132+1,132*2), SUBSTR(source_column, 132+1, length(source_column)) )

Column 3 - ifthenelse(length(source_column) > 132*3, SUBSTR(source_column,132*2 + 1,132*3), SUBSTR(source_column, (132*2)+1, length(source_column)) )

....and so on.

Alternatively you might want to have a look at Pivot Transform for your task.

sksaxena
Participant
0 Kudos

Hey Shubham,

Thanks a lot for the solution. It did help me.

Request you to look into extension to this scenario in my reply to Dirk (above).

Please share your inputs whatever you can suggest. It'll be really appreciable.

Thanks

Samarth

Former Member
0 Kudos

Suggestions given by Dirk above are just perfect.