Help Using API

Apr 21, 2011 at 1:58 PM

I have just started taking a look at this and have some questions about how to use it.
Some of these might be basic as I am still a novice with various aspects of C# and .NET.

Basically I am trying to do the following:

- Import all the transactions in the qif file
- Iterate through the transactions one by one (foreach loop?) and pull out various details I need, assigning to variables along the way.
- Once I have the information I need from each transaction I create an output line and dump it to a stream writer and save it somewhere else (there is other data here that makes up the whole and I need the transaction data to fill it in.

Where I am running into trouble is just after the import.  I cannot figure out how to get the data from the object in a way that I can iterate through each transaction.

What I have so far is minimal in regards to how to use this api - here are the extracted bits - if helping requires more context I can post more from the code.

 

                // get and save file from upload form
                string fileName = Server.MapPath("~/ExcelUpload/" + strGUID + ".csv");
                CSVFileUpload.PostedFile.SaveAs(fileName);

                // read imported file with qifdom api
                QifDom qd = new QifDom();
                qd.Import(fileName);
                
               

 

I looked through the source and the example api test that is posted with this project but I could not find this type of detail in either - or at least not in a way that I recognized as something usable for this matter.

Any help or advice is greatly appreciated.

Thanks,

Israel.

Coordinator
Apr 22, 2011 at 4:19 PM

The file passed to the qd.Import() method needs to be a QIF file (in the QIF file format). It appears you're trying to pass a CSV (comma separated value) file to qd.Import() which won't work. The concept of what you're asking for is indeed supported, but the incoming file (via the Import() method) must be a QIF file.

Apr 22, 2011 at 5:26 PM

Thanks for the reply.  I pasted mainly what I was trying to do conceptually with a definet understanding that a qif file must be used.  here is some spaghetti of what i am thinking is possible.  If you could help me understand how to do this it would be appreciated.

 

// get and save file from upload form
string fileName = Server.MapPath("~/Upload/" + strGUID + ".qif");
QIFFileUpload.PostedFile.SaveAs(fileName);

// read imported file with qifdom api
QifDom qd = new QifDom();
qd.Import(fileName);
 
// loop through transactions
foreach (QifApi.Transactions.BasicTransaction bt in qd.Import(fileName))
{
   // do something
}

The loop above doesn't work and i get an error about foreach not being usable on void types....  I am mainly trying to paint the picture of what I am trying to do and ask for help.

Thanks

- Israel.

 

Coordinator
Apr 22, 2011 at 6:28 PM

Thanks for the additional information and clarification. There are a few BasicTransaction lists you can enumerate over, but BankTransactions is probably the most common. I don't have a code environment at the moment, but something like the following should help you get started:

foreach (QifApi.Transactions.BasicTransaction bt in qd.BankTransactions)
{
	// do something
}

Apr 22, 2011 at 8:47 PM

Thank you. 

This was the hurdle and I am now working through using the api.

Israel.