# Trouble with converting api result to csv

**URL:** <https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568>\
**Category:** Help\
**Tags:** workflow\
**Created:** [January 24, 2020, 7:39pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568 "2020-01-24T19:39:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [January 24, 2020, 7:39pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568/1 "2020-01-24T19:39:45Z")

</div>

Working on worklow 5e1de0447cb6710007b558d1 , Virtual button B.

I struggle to format the result path containing the CSV string.  
Just want time stamp and each data point on each row.

I’m doing something wrong.

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [January 24, 2020, 7:48pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568/2 "2020-01-24T19:48:13Z")

</div>

Hi @Lars_Andersson,

Could you include some screenshots of your workflow, debug log, and node configurations?

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [January 24, 2020, 7:54pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568/3 "2020-01-24T19:54:07Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/a/a266a8870ac9bd570ac43984c57658caf67cb652.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/4967d5747af45ad0f7ff97b6bb0ce8b3a99c6211.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/4e63e1f11c9e9823ff84c134769aa1b59f939aea.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/8/8869658bb24d13503b0fa064d77e397ddcb58d9a.png)

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [January 24, 2020, 7:55pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568/5 "2020-01-24T19:55:01Z")

</div>

csv file look like this

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/0aa7b3d6405aab67b1ee5c7ff9e25453730780de.png)

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [January 24, 2020, 9:24pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568/6 "2020-01-24T21:24:44Z")

</div>

Hi @Lars_Andersson,

Understood. The CSV: Encode Node is not able to flatten nested data with your current configuration, but there are multiple ways you can go about solving this.

Your first option is to use a [Loop Node](https://docs.losant.com/workflows/logic/loop/) to move the values that exist in `data` to within the same object as `time`. This would give you an array that contains no nested objects and is easily converted by the CSV: Encode Node.

The second option would be to explicitly define your headers. In my testing, my data started with the same structure as yours above:

 ![Screen Shot 2020-01-24 at 4.22.07 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/eda66a6be077cac9744fda5f91993466b490d81f.png)

But by defining the individual headers I wanted, my CSV comes out as I expected:

 ![Screen Shot 2020-01-24 at 5.03.34 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/5/578c6d4bbcfa044f1072020c282bba222151661f.png)

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [January 24, 2020, 9:46pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568/7 "2020-01-24T21:46:05Z")

</div>

When try the second option, I only get the time field, even though I defined 2 more header values

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [January 24, 2020, 10:18pm UTC](https://forums.losant.com/t/trouble-with-converting-api-result-to-csv/2568/8 "2020-01-24T22:18:50Z")

</div>

Hi @Lars_Andersson,

I do apologize, that screenshot was not complete, it is updated now. You will need to use `data` as a prefix when selecting which values you would like in your CSV.

Thanks!  
Julia
