ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Trying to get an API Call to 400 using .net

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to get an API Call to 400 using .net

    I'd really appreciate some advice here. I've been trying to get an api call using c# and cwbx.dll. It seems right, but debugging it is pretty difficult.

    Code:
        private void apiCall(){
                string result =string.Empty;
     
                StringConverter stringConverter =new StringConverterClass();
     
                // Define an AS400 system and connect to it
                AS400System system = new AS400System();
                system.Define(ipaddress);
                system.UserID=user;
                system.Password=password;
                system.IPAddress=ipaddress;
                system.Connect(cwbcoServiceEnum.cwbcoServiceRemoteCmd);
     
                // Check the connection
                if(system.IsConnected(cwbcoServiceEnum.cwbcoServiceRemoteCmd)==1)
                {
                    // Create a program object and link to a system                
                    cwbx.Program program =new cwbx.Program();
                    program.LibraryName = library;
                    program.ProgramName = program;
                    program.system=system;
                    ProgramParameters parameters = new ProgramParameters();
                    parameters.Append("error", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("$error", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("$ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("&error", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("&ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80);
                    parameters.Append("ahpro", cwbrcParameterTypeEnum.cwbrcInout, 11);
                    parameters["ahpro"].Value = stringConverter.ToBytes(inputProNumber.Text.Trim().PadRight(11, ' '));
    
                    try
                    {
                        
                        program.Call(parameters);
                    }
                    catch(Exception ex)
                    {
                        if(system.Errors.Count>0)
                        {
                            foreach(cwbx.Error error in system.Errors)
                            {
                                Response.Write("System: " + error.Text + "<br />");
                                System.Diagnostics.Debug.WriteLine(error.Text);
                            }
                        }
     
                        if(program.Errors.Count>0)
                        {
                            foreach(cwbx.Error error in program.Errors)
                            {
                                Response.Write("Program: " + error.Text + "<br />");
                                System.Diagnostics.Debug.WriteLine(error.Text);
                            }
                        }
                    }
    
                        result = stringConverter.FromBytes(parameters["error"].Value);
                        Response.Write("result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["ERROR"].Value);
                        Response.Write("RESULT is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["$error"].Value);
                        Response.Write("$result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["$ERROR"].Value);
                        Response.Write("$RESULT is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["&error"].Value);
                        Response.Write("&result is " + result + "<br />");
                        result = stringConverter.FromBytes(parameters["&ERROR"].Value);
                        Response.Write("&RESULT is " + result + "<br />");
    
                }
     
                system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll);
                System.Diagnostics.Debug.WriteLine(result);
                Response.Write("result is " + result);
    Could anyone shed some light on how I would debug it if say.... the website never finished loading? I usually get a return code of null on the error parameter.

  • #2
    Re: Trying to get an API Call to 400 using .net

    Okay. Apparently the programmer clears the errors out of habit and since my website was looking for errors, the website never stopped looking. The programmer didn't clear the errors and now voodoo crazy errors come up for me. Which makes me feel better since the website actually loads now.

    Comment

    Working...
    X