@@ -201,13 +201,13 @@ protected Uri GetFullyQualifiedUri(string aRef)
201201 return new Uri ( GetFullyQualifiedRef ( aRef ) ) ;
202202 }
203203
204- internal Uri FormatCreateString ( string workspaceRef , string typePath )
204+ internal Uri FormatCreateUri ( string workspaceRef , string typePath )
205205 {
206206 String workspaceClause = workspaceRef == null ? "" : "?workspace=" + workspaceRef ;
207207 return new Uri ( Service . Server . AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + typePath + "/create.js" + workspaceClause ) ;
208208 }
209209
210- internal Uri FormatUpdateString ( string typePath , long objectId )
210+ internal Uri FormatUpdateUri ( string typePath , long objectId )
211211 {
212212 return
213213 new Uri ( Service . Server . AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + typePath + "/" + objectId +
@@ -464,7 +464,11 @@ public OperationResult Delete(string workspaceRef, string aRef)
464464 /// <returns></returns>
465465 public CreateResult Create ( string workspaceRef , string typePath , DynamicJsonObject obj )
466466 {
467- DynamicJsonObject response = CreateWithUri ( FormatCreateString ( workspaceRef , typePath ) , typePath , obj ) ;
467+ var data = new DynamicJsonObject ( ) ;
468+ data [ typePath ] = obj ;
469+ string postData = serializer . Serialize ( data ) ;
470+ DynamicJsonObject response =
471+ serializer . Deserialize ( Service . Post ( FormatCreateUri ( workspaceRef , typePath ) , postData , GetProcessedHeaders ( ) ) ) ;
468472 DynamicJsonObject createResult = response [ "CreateResult" ] ;
469473 var createResponse = new CreateResult ( ) ;
470474 if ( createResult . HasMember ( "Object" ) )
@@ -477,14 +481,6 @@ public CreateResult Create(string workspaceRef, string typePath, DynamicJsonObje
477481 return createResponse ;
478482 }
479483
480- public DynamicJsonObject CreateWithUri ( Uri uri , string typePath , DynamicJsonObject obj )
481- {
482- var data = new DynamicJsonObject ( ) ;
483- data [ typePath ] = obj ;
484- string postData = serializer . Serialize ( data ) ;
485- return serializer . Deserialize ( Service . Post ( uri , postData , GetProcessedHeaders ( ) ) ) ;
486- }
487-
488484 /// <summary>
489485 /// Update the item described by the specified reference with
490486 /// the fields of the specified object
@@ -497,22 +493,11 @@ public OperationResult Update(string reference, DynamicJsonObject obj)
497493 return Update ( Ref . GetTypeFromRef ( reference ) , Ref . GetOidFromRef ( reference ) , obj ) ;
498494 }
499495
500- public CreateResult CreateProjectTeamMembership ( String projectOid , String userOid )
496+ public DynamicJsonObject post ( String relativeUri , DynamicJsonObject data )
501497 {
502- Uri uri = new Uri ( String . Format ( "{0}slm/webservice/{1}/project/{2}/projectuser/{3}.js" , Service . Server . AbsoluteUri , wsapiVersion , projectOid , userOid ) ) ;
503- DynamicJsonObject data = new DynamicJsonObject ( ) ;
504- data [ "TeamMember" ] = true ;
505- DynamicJsonObject response = CreateWithUri ( uri , "projectuser" , data ) ;
506- DynamicJsonObject operationResult = response [ "OperationResult" ] ;
507- var createResponse = new CreateResult ( ) ;
508- if ( operationResult . HasMember ( "Object" ) )
509- {
510- createResponse . Object = operationResult [ "Object" ] ;
511- createResponse . Reference = createResponse . Object [ "_ref" ] as string ;
512- }
513- createResponse . Errors . AddRange ( DecodeArrayList ( operationResult [ "Errors" ] ) ) ;
514- createResponse . Warnings . AddRange ( DecodeArrayList ( operationResult [ "Warnings" ] ) ) ;
515- return createResponse ;
498+ Uri uri = new Uri ( String . Format ( "{0}slm/webservice/{1}/{2}" , Service . Server . AbsoluteUri , wsapiVersion , relativeUri ) ) ;
499+ string postData = serializer . Serialize ( data ) ;
500+ return serializer . Deserialize ( Service . Post ( uri , postData , GetProcessedHeaders ( ) ) ) ;
516501 }
517502
518503 /// <summary>
@@ -530,7 +515,7 @@ public OperationResult Update(string typePath, long oid, DynamicJsonObject obj)
530515 data [ typePath ] = obj ;
531516 string postData = serializer . Serialize ( data ) ;
532517 dynamic response =
533- serializer . Deserialize ( Service . Post ( FormatUpdateString ( typePath , oid ) , postData , GetProcessedHeaders ( ) ) ) ;
518+ serializer . Deserialize ( Service . Post ( FormatUpdateUri ( typePath , oid ) , postData , GetProcessedHeaders ( ) ) ) ;
534519 result . Errors . AddRange ( DecodeArrayList ( response . OperationResult . Errors ) ) ;
535520 result . Warnings . AddRange ( DecodeArrayList ( response . OperationResult . Warnings ) ) ;
536521 return result ;
0 commit comments