@@ -92,6 +92,7 @@ export class FeatureServiceAdmin {
9292 const eventFields = this . fields ( events )
9393 const layerFields = layerInfo . fields
9494
95+ // TODO - better naming: addFields is a boolean, array of fields, and a method. Ditto for deleteFields
9596 if ( featureLayer . addFields ) {
9697
9798 const layerFieldSet = new Set ( )
@@ -110,6 +111,7 @@ export class FeatureServiceAdmin {
110111 }
111112 }
112113
114+ // TODO - where does New_field and New_field_2 come from with each startup?
113115 if ( addFields . length > 0 ) {
114116 this . addFields ( service , featureLayer , addFields )
115117 }
@@ -462,24 +464,27 @@ export class FeatureServiceAdmin {
462464 */
463465 private async addFields ( service : FeatureServiceConfig , featureLayer : FeatureLayerConfig , fields : Field [ ] ) {
464466
465- const layer = { } as Layer
466- layer . fields = fields
467+ const layer = { fields : fields } as Layer
467468
468469 const httpClient = this . httpClient ( service )
469470 const identityManager = await getIdentityManager ( service , httpClient )
470471 const url = this . adminUrl ( service ) + featureLayer . layer . toString ( ) + '/addToDefinition'
471472
472473 this . _console . info ( 'ArcGIS feature layer addToDefinition (add fields) url ' + url )
473474
474- const form = new FormData ( )
475- form . append ( 'addToDefinition' , JSON . stringify ( layer ) )
476-
477- const postResponse = request ( url , {
475+ await request ( url , {
478476 authentication : identityManager ,
479- httpMethod : 'POST' ,
480- params : form
477+ params : {
478+ addToDefinition : JSON . stringify ( layer ) ,
479+ f : "json"
480+ }
481+ } ) . then ( ( postResponse ) => {
482+ console . log ( 'Response: ' + postResponse )
483+ } ) . catch ( ( error ) => {
484+ console . log ( 'Error: ' + error )
481485 } ) ;
482- console . log ( 'Response: ' + postResponse )
486+
487+ console . log ( 'Remove me' )
483488
484489 }
485490
@@ -507,14 +512,12 @@ export class FeatureServiceAdmin {
507512
508513 this . _console . info ( 'ArcGIS feature layer deleteFromDefinition (delete fields) url ' + url )
509514
510- const form = new FormData ( )
511- form . append ( 'deleteFromDefinition' , JSON . stringify ( layer ) )
512-
513- httpClient . sendPostForm ( url , form )
514515 const postResponse = request ( url , {
515516 authentication : identityManager ,
516517 httpMethod : 'POST' ,
517- params : form
518+ params : {
519+ deleteFromDefinition : JSON . stringify ( layer )
520+ }
518521 } ) ;
519522 console . log ( 'Response: ' + postResponse )
520523 }
0 commit comments