C# SDK - BatchFacade with Collections

Former Member
Former Member $organization

Greetings,

We've been working with the latest C# SDK and have begun working with the BatchFacade. We are liking the REST API and the SDK so far!

We've read some past TLCC presentations and a few other resources we were able to find on the network. We were able to find our way around some of our initial questions. We are stumped on one thing and are hoping somebody out there has done this (or knows it's not possible at the moment).

So we've been able to successfully use the BatchFacade to batch some basic calls. i.e. we can take a session key, get a session object, pass the constituent ID into constituent Info and get the Constituent back in one batch response. It makes sense and it works well.

Now we're interested in trying to feed a collection of attributes (ids, etc) into a batch request. We were wondering how to structure the DependsOnRequest and BatchRequest objects needed to do this. For example, say we are trying to get all of the performances within a season (75). We would get the Performance Seasons first as a collection and then feed those Ids somehow into the GetAll method for Performances. Does the BatchFacade allow this? If so then how would we change the code below? In theory this would work if the Production Seasons returned a single object instead of a collection.

While this isn't a practical application for us right now, we were asking the question over here since we may soon see the need to use the BatchFacade this way... if it's possible to do so. We understand that if this doesn't work in the way we're hoping then we can just break this into a few requests in our code. Any insight is appreciated. Thanks so much for your time. Below, it's implied that our tessituraService has been properly instantiated and credentialed.

 var dependsOnRequestValid = new List<DependsOnRequest> {
new DependsOnRequest() {
Id = 1,
IsUrlDependency = true,
SourcePath = "Id",
TargetPath = "ProductionSeasonIds",
},
};

BatchResponse batchResponse = await tessituraService.BatchFacade
.With(tessituraService.BatchFacade.Txn.ProductionSeasons.GetAll("75", "", "", null))
.With(tessituraService.BatchFacade.Txn.Performances.GetAll("", "", "", dependsOnRequestValid))
.Call();
Parents
  • Former Member
    Former Member $organization

    Randolph,

    Batching isn't designed to do what you are trying to do.  DependsOnRequest can be used to take a value from a Response Object (Source) and pass it to another request via TargetPath.  It cannot pull from a source collection and automatically concatenate values.  For example, you could do a GET for a single Production Season and then use the Id from that response to pass to the next request, as follows (not that this would make sense to batch but...),

    var dependsOnRequestValid = new List<DependsOnRequest> {
    new DependsOnRequest() {
    Id = 1,
    IsUrlDependency = true,
    SourcePath = "Id",
    TargetPath = "productionSeasonId",
    },
    };

    BatchResponse batchResponse = await tessituraService.BatchFacade
    .With(tessituraService.BatchFacade.Txn.ProductionSeasons.Get("75")
    .With(tessituraService.BatchFacade.Txn.Performances.GetAll("", "", "{productionSeasonId}", dependsOnRequestValid))
    .Call();

    I'd have to double check with SDK Batching but I believe you would pass the target variable name in brackets as shown. That is how you do it when using batching directly when specifying the URL.

  • Former Member
    Former Member $organization in reply to Former Member

    Thanks so much for the clarification and the reply, Eric.

    Figured it was worth asking about. We can always create multiple batch calls to achieve our goal. We were just looking for all of the different ways we could architect things.

    We do like the new SDK and REST API so far and really appreciate the hard work that has gone into it. We like the direction that things are going in.

    From our (limited) experience we found that those curly braces are needed if the value is the primary key for the resource... i.e. the id value is concatenated on the end of the URL to retrieve the resource /CRM/Constituents/1234

    We're still learning a lot though so the info above may not be 100% true. Thanks again.

Reply
  • Former Member
    Former Member $organization in reply to Former Member

    Thanks so much for the clarification and the reply, Eric.

    Figured it was worth asking about. We can always create multiple batch calls to achieve our goal. We were just looking for all of the different ways we could architect things.

    We do like the new SDK and REST API so far and really appreciate the hard work that has gone into it. We like the direction that things are going in.

    From our (limited) experience we found that those curly braces are needed if the value is the primary key for the resource... i.e. the id value is concatenated on the end of the URL to retrieve the resource /CRM/Constituents/1234

    We're still learning a lot though so the info above may not be 100% true. Thanks again.

Children
No Data