We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How can I add value as a Additional parameter in WebMethodAdaptor?

I tried to make a treeview, where the json come from a server using POST operation. In the post method, I need to send value in the body. For this I use WebMethodAdaptor and addParams for add the value. Here is my code:

export class AppComponent implements OnInit {
public hierarchicalData: Object[];
public projectId = 'projectID';
public value = 'C03374EC2';
public field: Object;



public ngOnInit(): void {
new DataManager({
url: SERVICE_URI,
adaptor: new WebMethodAdaptor
}).executeQuery(new Query().addParams(this.projectId, this.value))
.then((e: ReturnOption) => this.hierarchicalData = <Object[]>e.result).catch((e) => true);
this.field = { dataSource: this.hierarchicalData, id: 'zoneID', text: 'zoneName', child: 'subZone' };

}

}

Now the problem is the WebMethodAdaptor send data in the following formats,

{"value":{"params":{"projectID":"C03374EC2"},"projectID":"C03374EC2"}}

But I need,

{ "projectID":"C03374EC2" }


1 Reply

CI Christopher Issac Sunder K Syncfusion Team April 1, 2019 12:52 PM UTC

Hi Md Jonayed, 

We have validated your query. Please check whether you have properly initializes the params in the serve side where you fetch the data. 
[Server side code] 
// initializes params at server side. 
public bool requiresCounts { get; set; } 
public int skip { get; set; } 
public int take { get; set; } 
public string data { get; set; } 
public Dictionary<string, object> @params { get; set; } 

While providing the above code snippet you will get the params in the following format. 
 

This is how the additional parameters get added from the server side request. 

For more information you can check the following documentation link 

Please check whether the provided information fulfills your requirement . If not, please share your code snippet (server side) or sample that replicates your issue if possible. 

Thanks,
Christo 


Loader.
Live Chat Icon For mobile
Up arrow icon