Join Features and save result as Layer view through the REST API

1337
4
Jump to solution
10-03-2019 05:47 AM
Raul_Jimenez
Esri Contributor

Context info: I'm just trying to write some documentation about how to get the most out of ArcGIS Online Hosted Feature Servicesand I have some questions I'd need a little help with.

I following this workflow to join two layers and save them as a layer view. Trying to do some reverse engineering using Postman and I have found seven POST requests are made during this process (Postman collection with those requests).

I have explored these requests and I have some questions:

  • I have seen the first two requests are createService and addToDefinition, specifying "isView: true" and updating the service definition (view SD) to specify information about the query parameters themselves.
    • Is this enough to have a layer view fully functional??

  • The third request updates the item "properties" field with a JSON that includes a "jobUrl" set to: "https://analysis7.arcgis.com/arcgis/rest/services/tasks/GPServer/JoinFeatures/jobs/ViewJob_1570094204566",
    • When was this job created?, I have filtered my browser network tab by "/JoinFeatures/submitJob" and I haven't found any request. 
    • Is this necessary? I make sense ... but I'm confused because I can't find when it is sent.

  • Fourth request is adding a JSON to the item's static resources with the name of the tool and parameters needed to run that tool (in this case: Join features)
    • Is this necessary for something?

  • Request 5, 6 and 7 are just update item metadata, thumbnail, tags, etc
    • I assume all these are optional too

Any help is more than welcome . Thanks in advance,

Raul

1 Solution

Accepted Solutions
Raul_Jimenez
Esri Contributor

I'm still not sure how to answer my previous questions, but I have been testing the requests and I made it work without using the jobUrl, adding the JSON to the static resources, etc.

I have created a Postman collection with all several requests I used in case you want to take a look at them:

  • There are three requests to create a brand new feature service (Awards) and populate it with data (requests: 4, 5 and 6):

    This screenshot shows the Beaches awarded in 1955 by three different organizations

  • Also, three requests to create a brand new feature service (Beaches) and populate it with data (requests: 1, 2 and 3):



    These screenshots show the names for each Beach awarded in 1955 on the Beaches table

  • Two requests to create the feature layer view (Awarded_beaches) with a join (Beaches.BeachId = Awards.BeachId)  (requests: 7 and 8):

    Here we can see the JOIN in action, and how we can see in the same table all the attributes from both tables.

So I'll check this question as solved .

Thanks,

Raul

View solution in original post

0 Kudos
4 Replies
Raul_Jimenez
Esri Contributor

Hi Atma Mani & Rohit Singh,

I have noticed you were the ones writing the documentation about the create_view method within the Python API. Maybe you know the answer to my questions or know who can I talk to .

Thanks in advance!,

Raul

0 Kudos
EarlMedina1
Occasional Contributor III

Hi Raul,

You are on the right track. I mentioned the rest operations briefly in this post: How to create hosted feature views including tables . At minimum, you need createService and addToDefinition to create the view. As I mention in the post, the easiest way to see what the params should be is to log the traffic. I think for what you have to do you need to run the join job first and then create the view from the result (unless for you workflow you need to create the view first and then the join?).

If you're not seeing the submitjob request, it may help to run the job in a browser and use the "Preserve Log" or "Persist Logs" option of the browser developer tools. Hope this helps!

-Earl

Raul_Jimenez
Esri Contributor

Thanks Earl,

I'll repeat the process again as soon as possible, but I'm pretty sure when I did it last time (logging the whole time) I didn't see any join task request (maybe I missed it).

I think for what you have to do you need to run the join job first and then create the view from the result (unless for you workflow you need to create the view first and then the join?)

As you can see, using the "Join Features" tool within the Web Map Viewer:

You can do the execute the join task and create the layer view in one step <- this was the workflow I followed, and I couldn't find the join task request anywhere.

Thanks one more time.

Raul

P.S: sorry for taking 3 days to reply, I'm pretty busy this weeks because our user conference is on 29th & 30th October ^_^''

0 Kudos
Raul_Jimenez
Esri Contributor

I'm still not sure how to answer my previous questions, but I have been testing the requests and I made it work without using the jobUrl, adding the JSON to the static resources, etc.

I have created a Postman collection with all several requests I used in case you want to take a look at them:

  • There are three requests to create a brand new feature service (Awards) and populate it with data (requests: 4, 5 and 6):

    This screenshot shows the Beaches awarded in 1955 by three different organizations

  • Also, three requests to create a brand new feature service (Beaches) and populate it with data (requests: 1, 2 and 3):



    These screenshots show the names for each Beach awarded in 1955 on the Beaches table

  • Two requests to create the feature layer view (Awarded_beaches) with a join (Beaches.BeachId = Awards.BeachId)  (requests: 7 and 8):

    Here we can see the JOIN in action, and how we can see in the same table all the attributes from both tables.

So I'll check this question as solved .

Thanks,

Raul

0 Kudos