This section describes how to login to the PerfectForms™ API using a C# example. Now that you have a form ready and you know the Web service address, you can create a test project with Visual Studio 2008.

|
| 1. | Double-click the file Form1.cs in Solution Explorer. The form Form1 will open in design mode. |
| 2. | Drag and drop a Label control and a TextBox control from the Toolbox to the form (if the Toolbox is not visible you can activate it using the menu View > Toolbox). |

| 3. | Now, with the new label selected, switch to the Properties Windows (if it is not visible you can activate it using the menu View > Properties Window) and then change the property Text to ‘UserName’. Select the TextBox and change the property Name to ‘txtUser’. |
| 4. | Add two more Label controls and two more TextBox controls. |
| 5. | Change the labels' Text property to ‘Password’ and ‘API Key’. Change the property Name for the textboxes to ‘txtPassword’ and ‘txtAPIKey’. |
| 6. | Select the txtPassword textbox and change the property ‘PasswordChar’ to ‘*’. |
| 7. | Drag and drop a Button control from the Toolbox to the form (if the Toolbox is not visible you can activate it using the menu View >Toolbox). |
| 8. | Change the new button's property Name to ‘btnLogin’ and the property Text to ‘Login’. |

| 9. | Double-click on the button in design mode and you will be taken to the source code view of the form, where you will write the code that will handle the button click event. |

| 10. | You must now add the code that does the actual login. You will need two global variables: a) a reference to the APISoapClient (API in VS2005) and b) the token that will be returned by the login function. |
| 11. | As Visual Studio offers Intellisense, you can type the name of the Web reference added (PerfectForms and then '.') and you will see a list with all the types exposed by the reference. |

| 12. | After the global variables are declared, initialize the API in the Form Load part: api = new PerfectForms.API(); (If you do not see the Form1_Load() then go to design mode and double-click on the form). |

| 13. | Now you must add the code to call the login method from the API. If you use the help provided by Intellisense you will see a list of methods that the API variable provides. |

| 14. | The Login method has the following signature: public int Login(string emailAddress, string password, string securityKey, out string token, out string firstName, out string lastName, out long maxAttachmentSize). You need to pass in the data that you collect from the user and pass it in to the respective fields in the Login method. |

| 15. | Now you can test your application. Go to the Visual Studio menu option Debug > Start Debugging, and when your form pops up, enter the required fields. Use the user name and password which has API enabled (see Setting API Account Access) and the key that was e-mailed to you. Next click the Login button. You should see a pop-up that informs you that the login was successful. |

|
Updated: 06/12/2011
Page url:
http://www.perfectforms.com/Documentation/manual/html/?api_logging_in.htm
PerfectForms™ -- forms software, workflow software, and business process management