Fail to create CVSrowset

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
If you need a quicker response, please create a support ticket via the customer portal my.goanywhere.com or contact our support team by email at [email protected].
4 posts Page 1 of 1

anutta78

Posts: 5
Joined: Fri Sep 09, 2016 11:59 am

Post by anutta78 » Fri Jul 07, 2017 7:04 am
Hello,

I have GA version 5.4.1
I need to send csv file to REST API
I created a project:
ReadCSV, WriteJson, POST Json to REST
2 issues:
1.My rowset loos like this in the json file
com.linoma.ga.projects.tasks.converters.csv.CSVRowSet@58dce226
2.POST command returns success but no files were sent..
Below project XML.
Thank you for you help
Code: Select all
<project name="send csv to REST" mainModule="Main" version="2.0" logLevel="verbose">

	<module name="Main">

		<readCSV inputFile="\Import\IC230-testanna2.csv" 
outputRowSetVariable="currentfilecontent"   fieldDelimiter="comma"   version="1.0">
			<data>
				<column index="1" />
				<column index="2" />
				<column index="3" />
				<column index="4" />
				<column index="5" />
				<column index="6" />
				<column index="7" />
				<column index="8" />
				<column index="9" />
				<column index="10" />
				<column index="11" />
				<column index="12" />
				<column index="13" />
				<column index="14" />
				<column index="15" />
				<column index="16" />
				<column index="17" />
			</data>
		</readCSV>


		<jsonWrite outputFile="\Import\jsonoutput.json" whenFileExists="overwrite" outputFileVariable="filetoporcess" version="1.0">
			<object name="{">
				<field name="Protocol" value="AnnaTest6" />
				<field name="FileContents" value="${currentfilecontent}" />
			</object>
		</jsonWrite>


		<restPost resourceId="Test_rest" uri="DIC230011/api/UserSiteImportTest/" inputFile="${filetoporcess}" contentType="application/json" responseBodyDestination="none" responseHeadersDestination="none" version="1.0" logLevel="debug" disabled="false">
			<header name="x-apiKey" value="12365478" />
		</restPost>

	</module>

</project>

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue Jul 11, 2017 11:30 am
You're using the Rowset Value incorrectly. The way you're using it is as a pointer (thus the "com.linoma.ga.projects.tasks.converters.csv.CSVRowSet@58dce226" value)

Try setting the contents of the CSV to a variable named "FileContents" like this:

<setVariable name="FileContents" inputFile="\Import\IC230-testanna2.csv" version="2.0" />

Then print that as the value needed inside your JSON file instead.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

Support_Tim

Posts: 35
Joined: Mon Dec 01, 2014 10:35 am

Post by Support_Tim » Tue Jul 11, 2017 1:13 pm
Hi Annuta78,

Your project appears to be trying to upload a JSON file created from a CSV file. The Write JSON seems to be the issue since you are seeing a successful post. Here is an example based on your project. It shows how you need to add the field elements for each column in the rowset, which is an array.

The HTTP Post is disabled, so you will need to enable it. Then just add the rest of your fields as I have done for columns 1-3, and consult the RESTful HTTP host’s documentation to see what format and labels are expected by the server.

If you are trying to post a CSV file, you would not need to read the data from it and create a JSON. You would simply post it with a post task like you have in your project.

Code: Select all
<project name="REST_POST send csv to REST" mainModule="Main" version="2.0" logLevel="debug">

                <module name="Main">

                                <createWorkspace version="1.0" />


                                <readCSV inputFile="C:\Users\TMcCall\Documents\_Case Docs\50313\Upload_Full_06Jul2017183019.csv" outputRowSetVariable="currentfilecontent" fieldDelimiter="comma" version="1.0">
                                                <data>
                                                                <column index="1" />
                                                                <column index="2" />
                                                                <column index="3" />
                                                                <column index="4" />
                                                                <column index="5" />
                                                                <column index="6" />
                                                                <column index="7" />
                                                                <column index="8" />
                                                                <column index="9" />
                                                                <column index="10" />
                                                                <column index="11" />
                                                                <column index="12" />
                                                                <column index="13" />
                                                                <column index="14" />
                                                                <column index="15" />
                                                                <column index="16" />
                                                                <column index="17" />
                                                </data>
                                </readCSV>


                                <jsonWrite outputFile="${system.job.workspace}\jsonoutput.json" whenFileExists="overwrite" tidy="true" defaultNullSubstitute=" " outputFileVariable="filetoporcess" version="1.0">
                                                <object name="wrapper">
                                                                <array name="Data" inputRowSetVariable="${currentfilecontent}">
                                                                                <object name="{">
                                                                                                <field name="Site Code" value="${currentfilecontent[1]}" />
                                                                                                <field name="Site Name" value="${currentfilecontent[2]}" />
                                                                                                <field name="Primary Investigator" value="${currentfilecontent[3]}" />
                                                                                </object>
                                                                </array>
                                                </object>
                                </jsonWrite>


                                <restPost resourceId="[removed]" uri="DIC230011/api/UserSiteImportTest/" inputFile="${system.job.workspace}/${filetoporcess}" contentType="application/json" responseBodyDestination="none" responseHeadersDestination="none" version="1.0" logLevel="debug" disabled="true">
                                                <header name="x-apiKey" value="12365478" />
                                </restPost>


                                <deleteWorkspace version="1.0" />

                </module>

</project>

anutta78

Posts: 5
Joined: Fri Sep 09, 2016 11:59 am

Post by anutta78 » Wed Jul 12, 2017 9:29 am
Support_Rick wrote:
You're using the Rowset Value incorrectly. The way you're using it is as a pointer (thus the "com.linoma.ga.projects.tasks.converters.csv.CSVRowSet@58dce226" value)

Try setting the contents of the CSV to a variable named "FileContents" like this:

<setVariable name="FileContents" inputFile="\Import\IC230-testanna2.csv" version="2.0" />

Then print that as the value needed inside your JSON file instead.

THANK YOU, Rick!
4 posts Page 1 of 1