Kidd Mahobele
Kidd Mahobele

Reputation: 53

IQ Retail API not returning Invoice data

I am trying to do an invoice request on IQIntAPI and I am getting the below error message

<?xml version="1.0" encoding="UTF-8"?>
<IQ_API_Result>
   <IQ_API_Error>
      <IQ_Error_Code>5</IQ_Error_Code>
      <IQ_Error_Description>Unable to open Data Tables for Company [FMC]</IQ_Error_Description>
      <IQ_Error_Data>
         <IQ_Error_Data_Item>
            <IQ_Error_Code>7</IQ_Error_Code>
            <IQ_Error_Description>IQ_User_Password Is Invalid</IQ_Error_Description>
            <IQ_Error_Extended_Data />
         </IQ_Error_Data_Item>
         <IQ_Error_Data_Item>
            <IQ_Error_Code>5</IQ_Error_Code>
            <IQ_Error_Description>Unable to open Data Tables for Company [FMC]</IQ_Error_Description>
            <IQ_Error_Extended_Data />
         </IQ_Error_Data_Item>
      </IQ_Error_Data>
   </IQ_API_Error>
</IQ_API_Result>

Company_Number, IQ_Terminal_Number, IQ_User_Number and IQ_User_Password is correct for the API user I have tried running the REST Server, giving all access permissions to Company Folder but the API still gives the same error.Below is part of my sourcecode:

IntPtr FResult;
            string FResultString;
            int FResultLength;
            string FMessage;
            int FMessageLength;
            int FCallResult;

            StringWriter FStringWriter = new StringWriter();

            using (XmlWriter FWriter = XmlWriter.Create(FStringWriter))
            {
                FWriter.WriteStartDocument();

                FWriter.WriteStartElement("IQ_API");
                FWriter.WriteStartElement("IQ_API_Request_Document_Invoice");
                FWriter.WriteElementString("IQ_Company_Number", "FMC");
                FWriter.WriteElementString("IQ_Terminal_Number", "1");
                FWriter.WriteElementString("IQ_User_Number", "100");
                FWriter.WriteElementString("IQ_User_Password", "KIDD");
                FWriter.WriteEndElement(); //IQ_API_Request_Stock                   
                FWriter.WriteEndElement(); //IQ_API                
                FWriter.WriteEndDocument();
                FWriter.Flush();
            }


            FMessage = FStringWriter.ToString();
            FMessageLength = FMessage.Length;
            FResultLength = 0;

            FCallResult = IQ_API_Request_Document_Invoice(FMessage, FMessageLength, out FResult, ref FResultLength);
            FResultString = Marshal.PtrToStringAnsi(FResult);

            if (FCallResult != 0)
            {
                MessageBox.Show("An Error Occurred. Error Code [" + FCallResult.ToString() + "]");
            }
            lstResult.Text = FormatXML(FResultString.Substring(0, FResultLength));

Where might I be going wrong in my source code or IQ Retail setup?

Upvotes: 0

Views: 231

Answers (1)

Cipher Breaker
Cipher Breaker

Reputation: 26

My response may be very late, but I hope my answer will help the next person in the future to solve this issue.

If you are using 'IQEntAPITest.exe' which you will typically find in this directory

C:\IQRetail\IQEnterprise\IQEntAPITest.exe

or where ever you've installed IQ, you can use your password as it is. IQEntAPITest converts the password in the background for you into SHA1, hence you can use your direct password.

In this case, you are not using IQEntAPITest, therefore you will need to SHA1 your password and make sure the letters in the newly generated SHA1 password are in upper-case. Copy and paste that password in your code. You should be fine.

Upvotes: 1

Related Questions