Select to view content in your preferred language

How to use Esri::ArcGISRuntime::Portal to connect to my own portal

2312
13
10-08-2018 06:17 AM
NorbertThoden
Occasional Contributor III

Hi!

I would like to get information about the service urls privided at my onw portal.

So like to start with Esri::ArcGISRuntime::Portal, but how?

  1. There are so many examples using Portal, don´t know where is a simple on (as less QML as possible)?
  2. How do i get my url? (one of my REST-URLs is
    "http://XXXX.de/arcgis/rest/services/Bremen/BremenElevation/ImageServer "
  3. Do i have to use credentials? I would like to start very simple, just get list of basemap or items...)
  4. Got errorCode 25, like error occured realted to SSL...
    Pltaform codes are NOT here (Error Class | ArcGIS for Developers ), but would be nice to have i link...
    Should be here (Platform error codes—ArcGIS Runtime SDK for .NET (WPF) | ArcGIS for Developers )?
    But can`t find code 25....
  5. My Portal doesn´t have a CA, so using the browser i have to accept ssl messages od create exception.
    Will it work?

Thx in advance!

Norbert

0 Kudos
13 Replies
LucasDanzinger
Esri Frequent Contributor

here is some example code. you can modify your search string to find the different items you need. for example, you can specify type, tags, name, etc. Here are some details on how you can customize it - Search reference—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers  

// create portal with url and credential
Credential* cred = new Credential("username", "password", this);
m_portal = new Portal(QUrl("https://arcgis.com"), cred, this);

// connect to done loading
connect(m_portal, &Portal::doneLoading, [this](Error e)
{
  if (!e.isEmpty())
  {
    qDebug() << e.message() << e.additionalMessage();
    return;
  }

  // connect to findItemsCompleted
  connect(m_portal, &Portal::findItemsCompleted, [](PortalQueryResultSetForItems* items)
  {
    // loop through results
    for (int i = 0; i < items->itemResults()->size(); i++)
    {
      auto item = items->itemResults()->at(i);

      // load the item
      connect(item, &PortalItem::doneLoading, [item](Error e)
      {
        if (!e.isEmpty())
          return;

        qDebug() << item->name();
      });
      item->load();
    }
  });

  PortalQueryParametersForItems queryParams;
  queryParams.setSearchString(R"(type:"map service")");
  m_portal->findItems(queryParams);
});

// load the portal
m_portal->load();
0 Kudos
NorbertThoden
Occasional Contributor III

Hi Luke, i would like to continue using V100.6 now:

In the meantime i was able do an OfflineMapTask using a webmap . So im in touch with the portal now.

But the authentication is still a black box, so i skipped that

(Credentials, authManager .. no idea, How i can verify, that openSSL ist working?)

I want to iterate over the items the portal is hosting, maybe list the map services, list the webmaps or similar.

So i tried, fetchBasemaps,  fetchFeaturedGroups, fetchFeaturedItems, fetchHomepageFeaturedContent.

Perform some find operations, but no adequat result 😞

Most of the time empty lists, because the portal is nearly empty.

But only a few map services are discovered using the SDK, Is that limited to 10?

(I have ~75 Map Services, ~30 are shared. And shared is public to everyone on my portal)

Is there an sample which discovers an portal?

Has someone overcome the authentication (SDK) of an own portal?

One usecase shoudl be listing the Map Services and/or WebServices. And getting the thumbnail of the map would be the cherry on the cake 🙂

My portal has one user: portaladmin,

Since last week, there are only map services, nothing else.

If publishing a map services was successful, i shared that with everyone, no restictions!

No, portal, arcgisServer are in one network, the client in another. No idea how to change this...

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Hi Norbert, 

Have you tried running the Search for Webmaps sample? I think this should largely accomplish what you are wanting to do. To connect to your own portal, you will need to specify your Portal URL and specify that loginRequired is true in the constructor - https://github.com/Esri/arcgis-runtime-samples-qt/blob/master/ArcGISRuntimeSDKQt_CppSamples/CloudAnd...

If you run this sample from the sample viewer, it should work out of the box. If you run from the github project, you'll need to uncomment the AuthenticationView here - https://github.com/Esri/arcgis-runtime-samples-qt/blob/master/ArcGISRuntimeSDKQt_CppSamples/CloudAnd...

You aren't required to use the AuthenticationView in your solution. The general idea is that the AuthenticationManager handles all network challenges that are issued. For example, if you create a Portal object with a URL to your org and set loginRequired to true, when you load() that Portal, it will send a request to the Portal, a challenge will be issued, and the authenticationChallenge signal will emit on the AuthenticationManager singleton - https://developers.arcgis.com/qt/latest/cpp/api-reference/esri-arcgisruntime-authenticationmanager.h.... It is then up to you to fulfill that challenge or ignore it. If the signal returns and you haven't done anything with the AuthenticationChallenge, it will go out of scope and the authentication will fail. If you want to fulfill the challenge, you will call one of the "continue" methods and pass in valid credentials. This is discussed in the AuthenticationManager section here - https://developers.arcgis.com/qt/latest/cpp/guide/access-the-arcgis-platform.htm

0 Kudos
NorbertThoden
Occasional Contributor III

Hi Luke!

Thanks for pointing me to the Search for Webmaps sample .-)

I can run it from the source code (on linux, using your portal):

  • portal is connected (since m_portal->loadStatus() == LoadStatus::Loaded;)

I can type "usa" and click search:

  • slot to findItemsCompleted is called,
    The m_webmapResults->itemResults()->size() is 10,
    but the ListView (?) is empty ...

QMetaProperty::read: Unable to handle unregistered datatype 'QAbstractListModel*' for property 'SearchForWebmap_QMLTYPE_1::webmaps'
QMetaProperty::read: Unable to handle unregistered datatype 'QAbstractListModel*' for property 'SearchForWebmap_QMLTYPE_1::webmaps'
qrc:/Samples/CloudAndPortal/SearchForWebmap/SearchForWebmap.qml:91:9: Unable to assign [undefined] to bool

Maybe the sample is outdated?

I change the ctor of the portal to use my portal -> no LineEdit is visible to do a search 😞

qrc:/Samples/CloudAndPortal/SearchForWebmap/SearchForWebmap.qml:91:9: Unable to assign [undefined] to bool

thx

0 Kudos