Library Version: 1.3.3
Targeting: SharePoint online
Requests to taxonomy should work with batching
Accessing the taxonomy without batching works:
let result:any[] = await TaxonomyService.Test(Constants.FORMS_TERMSET_ID);
console.log(result);
export class TaxonomyService {
public static async Test(termsetId: string): Promise<(ITermData & ITerm)[]> {
let terms: (ITermData & ITerm)[];
terms = await taxonomy.getDefaultSiteCollectionTermStore().getTermSetById(termsetId).terms.select('Id', 'Name').get();
return terms;
}
}
After adding the same request to a batch it errors out ("Invalid Request"):
let batch:SPBatch = sp.web.createBatch();
let result:Promise<any[]> = TaxonomyService.Test(Constants.FORMS_TERMSET_ID,batch);
await batch.execute();
console.log(result);
export class TaxonomyService {
public static async Test(termsetId: string, batch): Promise<(ITermData & ITerm)[]> {
let terms: (ITermData & ITerm)[];
terms = await taxonomy.getDefaultSiteCollectionTermStore().getTermSetById(termsetId).terms.select('Id', 'Name').inBatch(batch).get();
return terms;
}
}
The request payload seems to be missing the xml for the request body:
--batch_572f04ba-e21e-47e1-92d1-78fb0d0003e7
Content-Type: multipart/mixed; boundary="changeset_8581f7e1-c094-4dc1-adfc-029830d0d165"
--changeset_8581f7e1-c094-4dc1-adfc-029830d0d165
Content-Type: application/http
Content-Transfer-Encoding: binary
POST https://snsdev2.sharepoint.com/sites/Expense1/_vti_bin/client.svc/ProcessQuery? HTTP/1.1
accept: */*
content-type: application/json;odata=verbose;charset=utf-8, text/xml
x-clientservice-clienttag: PnPCoreJS:@pnp-1.3.3
--changeset_8581f7e1-c094-4dc1-adfc-029830d0d165--
--batch_572f04ba-e21e-47e1-92d1-78fb0d0003e7--
This seems to already have been an issue before in #419
Add the code above to a new project and run.
I think you need to use the batch from the correct library. The sp batch and taxonomy batch objects are not identical. Try this:
// use this one
const batch = taxonomy.createBatch()
Wow great, thanks @patrick-rodgers !
I didn't know that there's a separate batch object for taxonomy. It works perfectly using the correct one.
Most helpful comment
Wow great, thanks @patrick-rodgers !
I didn't know that there's a separate batch object for taxonomy. It works perfectly using the correct one.