Skip to main content
Published: May 05 2009, 12:41:00 PMUpdated: November 28 2020, 5:27:08 PM

 

XML sample for createDSRSummaryByPeriod using C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Xml;
using System.IO;

namespace FeedbackService
{
    class Program
    {
        static void Main(string[] args)
        {
            string token = "Your_Token";
            string serverURL = "https://svcs.ebay.com/FeedbackService";
            string service = "FeedbackService";
            string operation = "createDSRSummaryByPeriod";
            string dateFrom = "2009-04-01T00:00:00.000Z";
            string dateTo = "2009-04-30T00:00:00.000Z";
            string response;
            string result;

            //Construct the request
            string strReq = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
            + "<createDSRSummaryByPeriodRequest xmlns=\"http://www.ebay.com/marketplace/services\">"
            + "<dateRange>"
            + "<dateFrom>" + dateFrom + "</dateFrom>"
            + "<dateTo>" + dateTo + "</dateTo>"+ "</dateRange>"
            + "</createDSRSummaryByPeriodRequest>";

            //create a web request object
            HttpWebRequest
req = (HttpWebRequest)WebRequest.Create(serverURL);

            //Add the request headers
            req.Headers.Add("X-EBAY-SOA-SECURITY-TOKEN", token);
            req.Headers.Add("X-EBAY-SOA-OPERATION-NAME", operation);
            req.Headers.Add("X-EBAY-SOA-SERVICE-NAME", service);
            req.Headers.Add("X-EBAY-SOA-REQUEST-DATA-FORMAT", "XML");
            req.Headers.Add("X-EBAY-SOA-RESPONSE-DATA-FORMAT", "XML");
            req.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");

            //set the method to POST
            req.Method = "POST";

            //create a web response object
            HttpWebResponse resp = null;

            //Convert the string to a byte array
            byte[] postDataBytes = System.Text.Encoding.Default.GetBytes(strReq);
            req.ContentLength = postDataBytes.Length;

            //Post the request to eBay
            System.IO.Stream requestStream = req.GetRequestStream();
            requestStream.Write(postDataBytes, 0, postDataBytes.Length);
            requestStream.Close();

            try
            {
                // get response and write to console
                resp = (HttpWebResponse)req.GetResponse();
                StreamReader responseReader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
                response = responseReader.ReadToEnd();
                resp.Close();

                //Load the XML response and extract the jobID from the response
                System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
                xml.LoadXml(response);
                result = "jobID: " + xml.GetElementsByTagName("jobId")[0].InnerXml;
            }
            catch (Exception ex)
            {
                //handle exception
                result = ex.Message;
            }

            Console.WriteLine(result);
            Console.WriteLine("Press any key to exit");
            Console.ReadLine();

        }
    }
}

 

How well did this answer your question?
Answers others found helpful