Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


zuvefox
2011-07-06T07:21:54Z
hi..
how to change or set network credential on TASK using visualcron API ?
I used:
Dim j As New JobClass()
j.Name = "Shutdown"
j.Task("[TaskID]").Execute.NetworkCredential="[Credential Name]"

but result error with error description: Obect Reference not set to an instance of an object
thanx
Sponsor
Forum information
ErikC
2011-07-06T11:16:31Z
Hi zuvefox,

To set the credentials to a task you need the right credential key.
The server object holds all the credentials and their keys. They are strings. So look there for the right string.

Every task is specific in doing something, like an HTML task.
The task object should have a lot of properties in the HTML section of the task.
In there you will find credential settings where you can set the credential, like:

Server s = new Server();
TaskClass t = new TaskClass();
...
t = s.Jobs.Tasks.Get("qwertyuio-asdf-zxcv-1234-poiuytrreewwq");
t.HTTP.NetworkCredential = "1234567-abcd-1234-abcd-1234567890ab";
s.Jobs.Tasks.Update(t);


Regards,
Erik
Uses Visualcron since 2006.
zuvefox
2011-07-07T04:50:55Z
thanx for your response

I also get same error when i run that code.
error on t.HTTP.NetworkCredential = "1234567-abcd-1234-abcd-1234567890ab";
with error message: Object reference not set to an instance of an object.

credential key I got from networkcredentials.xml on tag <Id>

thanx
ErikC
2011-07-07T06:11:56Z
Hi zuvefox,

It's ok to get the key from the networkcredentials.xml file. That's the same key I refer to in my previous post.

I gave an example of a HTTP task. I do not know which type your task is, but you might need a different approach:

t.TASKTYPE....Credential = "1234567-abcd-1234-abcd-1234567890ab";

Please use the intellisense in Visual Studio to find your task type.

You can also use a breakpoint on this line an look in the Locals window for you t variable. Expand this and see where the tasktype is filled. (A lot of tasktypes have the value null, you can skip these)
Expand this and you might see your credential settings there. Use the full path to the credential and you have your code line.

Success guaranteed! 😎
Erik
Uses Visualcron since 2006.
Support
2011-07-07T07:09:02Z
Originally Posted by: zuvefox 

thanx for your response

I also get same error when i run that code.
error on t.HTTP.NetworkCredential = "1234567-abcd-1234-abcd-1234567890ab";
with error message: Object reference not set to an instance of an object.

credential key I got from networkcredentials.xml on tag <Id>

thanx



Which object is null? If HTTP object is null you need to create a HTTP object like this:

            TaskClass t = new TaskClass();
            t.TaskType = TaskClass.TaskT.HTTP;
            t.CreateTaskTypeObject();
            t.HTTP.NetworkCredential = "NetworkCredentialId";


or

            TaskClass t = new TaskClass();
            t.TaskType = TaskClass.TaskT.HTTP;
            t.HTTP = new TaskHTTPClass();
            t.HTTP.NetworkCredential = "NetworkCredentialId";

Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
zuvefox
2011-07-07T07:37:18Z
I got

I use task system shutdown so script should:

tc.SystemShutdown.Credential = "bb4baeb9-0b0d-4526-8975-c13d1b123456"

:)
thanx for your information
Support
2011-07-07T07:38:23Z
Originally Posted by: zuvefox 

I got

I use task system shutdown so script should:

tc.SystemShutdown.Credential = "bb4baeb9-0b0d-4526-8975-c13d1b123456"

:)
thanx for your information



Ok, so it works now?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
zuvefox
2011-07-07T07:45:10Z
Scroll to Top