Post

2 followers Follow
0
Avatar

Issues getting started with API in .NET

Hello,

I am trying to get started using the Clarizen API in .NET. I am using VS 2013. I have downloaded the ClarizenClient example to work from, but I am having a problem connecting to the API.

Following the steps from here: https://success.clarizen.com/hc/en-us/articles/205711818 I added a Web Refence to here: https://api.clarizen.com/v2.0/Clarizen.svc . When I did add the Service in Visual Studio, I got a warning saying "Do you want to view only the webpage content that was delivered securely?" I've tried answering both 'Yes' and 'No'. Either answer didn't seem to make a difference.

Running the ClarizenClient.exe that came with the downloaded sample, I am able to log into Clarizen and view my tasks. However I cannot seem to do the same with my basic example. When I get to the LoginResult line of the code, it hangs for a bit and then I get the error, "Unable to automatically step into the server. Connecting to the server machine api2.clarizen.com failed..."

Can you help provide some insight to what I am doing wrong?

Thank you.


Here's the code of my simple login test:
private void loginTest()
{
string userName;
string password;

userName = "MyUserName";
password = "MyPassword";

ClarizenSvc.Clarizen clarizenClient = new ClarizenSvc.Clarizen();
clarizenClient.Timeout = 60 * 1000;

//Enhance performance by compressing traffic
clarizenClient.EnableDecompression = true;

//Set your applicationId if applicable
LoginOptions options = new LoginOptions();

options.ApplicationId = "Sample c# client";

//Contact the login server to get the URL of your data center
GetServerDefinitionResult srvDef = clarizenClient.GetServerDefinition(userName, password, options);

//Change the SOAP client endpoint to use the new URL
clarizenClient.Url = srvDef.ServerLocation;

//Call the Login method
LoginResult lr = clarizenClient.Login(userName, password, options);
}

Robert Goodman Answered

Please sign in to leave a comment.

3 comments

1
Avatar

Hi HayMob,

As for the secured content warning, I'd go for 'No' (display all contents). Anyway, it's just a warning for displaying the web service page in the VS browser. Once you created the web service proxy it doesn't matter and it looks like you have managed to connect.

As for debugging the Web service consumer, do not try to step into the service methods (like Login). Obviously you cannot debug the Clarizen internal code that lies on Clarizen servers (you can debug just your code), so the correct way to go is to step over those lines. This applies for any Web service consumer methods (not just Clarizen's).

Hope this helps,

Ophir

Ophir Kenig 1 vote
Comment actions Permalink
0
Avatar

Hi Ophir,

The problem I am having is that I cannot connect using the code I listed. I am getting this error:

"Unable to automatically step into the server. Connecting to the server machine api2.clarizen.com failed..."

Any idea why that might occur with the code I've shown?

Thank you.

Robert Goodman 0 votes
Comment actions Permalink
0
Avatar

Hi HayMob,

Don't step into those statements (F11), step over them (F10).

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink