# Serialize DataSource Request of Grid and Post It to Another Backend Service

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Grid</td>
 </tr>
 <tr>
  <td>Product Version</td>
  <td>2019.3.917</td>
 </tr>
 <tr>
  <td>ASP.NET Core Version</td>
  <td>3.0</td>
 </tr>
</table>

## Description

I've started using SpreadStreamProcessing and I'm now trying to get it to work with my existing code. I would like to pass the `DataSourceRequest` to another method and use it to generate an excel file. How can I post the existing request?

## Solution

1. For get requests, you can use an approach similar to the one demonstrated in [this forum post](https://www.telerik.com/forums/connecting-asp-net-mvc-application-to-asp-net-webapi#f_CGsEPUa0KwgTJ8SEXPIg).
2. For the standard POST request, you need to serialize the Form request in the same way as the grid request does it.

```C#
    public ActionResult ReadOrders([DataSourceRequest]DataSourceRequest request)
    {
        var req = JsonConvert.SerializeObject(HttpContext.Request.Form);
        
        ProcessRequest(req);
        
        return Json(orders.ToDataSourceResult(request));
    }

	private async void ProcessRequest(string request)
    {
        HttpClient httpClient = new HttpClient();
        var formItems  = new List<KeyValuePair<string,string>>();
        httpClient.DefaultRequestHeaders.Add("X-Requested-With", "XMLHttpRequest");
        var values = JsonConvert.DeserializeObject<List<KeyValuePair<string,List<string>>>>(request);
        foreach (var keyValuePair in values)
        {
            formItems.Add(new KeyValuePair<string,string>(keyValuePair.Key), keyValuePair.Value[0]));
        }
        var form = new FormUrlEncodedContent(formItems);
        var response = httpClient.PostAsync("https://SomeOtherDomain.com/SomeController/ReadOrders", form).Result;
        string resWithFilter = await response.Content.ReadAsStringAsync();
        List<OrderViewModel> savedResult = JsonConvert.DeserializeObject<ResultData>(resWithFilter).Data;
    }

```

## More ASP.NET MVC Grid Resources

* [ASP.NET MVC Grid Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview)

* [ASP.NET MVC Grid Demos](https://demos.telerik.com/aspnet-mvc/grid/index)

* [ASP.NET MVC Grid Product Page](https://www.telerik.com/aspnet-mvc/grid)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/grid)
* [Server-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/grid)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
