phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

An uncaught Exception was encountered

Open aman90attari opened this issue 4 years ago • 3 comments

An uncaught Exception was encountered Type: Error

Message: Call to a member function getSegment() on null

Filename: C:\wamp64\www\rest\vendor\vgrem\php-spo\src\Runtime\ClientObject.php

Line Number: 235

While executing CAML Query above error is coming

I am using below code

$list = $ctx->getWeb()->getLists()->getByTitle("Employees"); //$list = $ctx->getWeb()->getLists()->getByTitle("Tasks"); $qry = new CamlQuery(); $qry->ViewXml = "<View><Query><Where><Eq><FieldRef Name='ID'/><Value Type='Integer'>10</Value></Eq></Where></Query></View>"; $qry->ViewXml = '<View><Query><Where><Eq><FieldRef Name="ID"/><Value Type="Integer">10</Value></Eq></Where></Query></View>'; $items = $list->getItems($qry); $ctx->load($items); $ctx->executeQuery(); foreach ($items as $index => $item){ print($index . ":" . $item->getProperty('ID') . PHP_EOL); print($index . ":" . $item->getProperty('FirstName') . PHP_EOL); }`

Also tried for <Value Type='Text'> and <Value Type='Number'> as mention here

Its giving blank screen when search value put like <Value Type='Integer'><10></Value>

aman90attari avatar Jun 16 '20 07:06 aman90attari

It's very interesting how completely incorrect CAML could lead to a failing request? :D CAML is XML with a specific schema.

koltyakov avatar Jun 16 '20 07:06 koltyakov

@koltyakov, Sorry for posted question, code was not warped inside that's why its changing from

$qry->ViewXml = '<View><Query><Where><Eq><FieldRef Name="ID"/><Value Type="Integer">10</Value></Eq></Where></Query></View>';

to

$qry->ViewXml = '10'; now i edited it.

aman90attari avatar Jun 16 '20 08:06 aman90attari

Hi there, Is there any method available through that I could get Sharepoint list row by ID? Please let me know if it is possible in other ways. I am using Sharepoint 2016.

aman90attari avatar Jun 17 '20 08:06 aman90attari