Adrian_Star
(Adrian Starukiewicz)
January 23, 2020, 12:36pm
1
Hi,
how can I get all specified values from the API response: list of data collections contained in GetJobs Response
in a for each
loop?
Response GetJobs
is in ODataResponseOfListOfJobDto
variable type.
I need to get 4 values from each entry:
"value": [ { "StartTime", "EndTime", "Status", "ReleaseName" }]
For example. The counter for the first case shows 78 results.
I know that I have to do it in a for each loop
, but I can’t pass it to the loop in ODataResponseOfListOfJobDto
variable type.
I don’t know what type of variable use to convert API Response to process data in loop.
Should I use conversion to a list, to a collection, to array, or maybe to json?
@loginerror , @mike.vansickle
bcorrea
(Bruno Correa)
January 23, 2020, 6:42pm
2
Deserialize JSON would be the best option.
Adrian_Star
(Adrian Starukiewicz)
January 23, 2020, 7:00pm
3
I tried to convert ODataResponseOfListOfJobDto
to json
format in Deserialize JSON
activity, but there were errors.
bcorrea
(Bruno Correa)
January 23, 2020, 7:01pm
4
Please tell us which activity are you using to make the request to get jobs.
Adrian_Star
(Adrian Starukiewicz)
January 23, 2020, 7:10pm
5
I have created custom Library with API request from this link:
Additionaly I.m using UiPath.Web.Activities
.
The problem is that this functionality has no documentation.
bcorrea
(Bruno Correa)
January 23, 2020, 7:15pm
6
well that would be impossible for us to help without knowing… that type does looks like it is a list, so it would work in for each, just adjust the type accordingly, for testing leave as object and in debugger you can see for sure.
Adrian_Star
(Adrian Starukiewicz)
January 23, 2020, 7:18pm
7
I have half a day of failed tests behind me. I will check back tomorrow and send my attempts to the topic.
Adrian_Star
(Adrian Starukiewicz)
January 24, 2020, 6:06am
8
@bcorrea
Here are the parameters of GetJobs
from API custom library:
I went deeper and found something like this
After sending a query about the phrase:
getJobsResponse.Value.ToString
I got response
System.Collections.Generic.List'1[UiPathWebApi.JobDto]
JobDto
Represents a scheduled or manual execution of a process on a robot. Supported method: Get.
JobDto Properties from Documentation
UiPath Orchestrator API Guide 2016.2
name
type
nullable
Description
Key
Edm.Guid
false
The unique job identifier.
StartTime
Edm.DateTimeOffset
The date and time when the job execution started or null if the job hasn’t started yet.
EndTime
Edm.DateTimeOffset
The date and time when the job execution ended or null if the job hasn’t ended yet.
State
UiPath.Core.Enums.JobState
false
The state in which the job is. Possible values: Pending, Running, Canceling, Terminating, Faulted, Successful or Canceled.
Source
UiPath.Core.Enums.JobSource
false
The Source of the job. Possible values: Manual or Schedule.
BatchExecutionKey
Edm.Guid
false
The unique identifier grouping multiple jobs. It is usually generated when the job is created by a schedule.
Info
Edm.String
Additional information about the current job.
CreationTime
Edm.DateTimeOffset
false
The date and time when the job was created.
Id
Edm.Int64
false
The database unique identifier.
I made a few requests, here are the results I get:
getJobsResponse.Value.Count.ToString = 0
getJobsResponse.Value(0).Info.ToString = Object reference not set to an instance of an object
getJobsResponse.Value(0).Info.Count.ToString = Object reference not set to an instance of an object
I am not sure but probably this response does not return data. In other respone (Authenticate, GetQueuesDefinitions) I have data.
Adrian_Star
(Adrian Starukiewicz)
January 27, 2020, 11:05am
9
@bcorrea
Hi,
I found my mistake and solved problem.
Response in GetJobs
has NO DATA because I entered the phrase in flow incorrectly on dates when filtering.
It was:
StartTime gt 2020-01-26T23:59:59.00Z and StartTime lt 2020-01-19T00:00:00.00Z and HostMachineName eq ‘PV000xxx’
Should:
StartTime lt 2020-01-26T23:59:59.00Z and StartTime gt 2020-01-19T00:00:00.00Z and HostMachineName eq ‘PV000xxx’
After finding the error, the rest was done quickly.
Below, a shortened flow with key activities:
4 Likes
system
(system)
Closed
January 30, 2020, 11:05am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.