Link to home
Start Free TrialLog in
Avatar of Ria jain
Ria jain

asked on

Ebay Post-Order API Not Working

I want to "IssueCaseRefund" using ebay post-order API

i have used these Api Url for "IssueCaseRefund" details using post method

API Url is: POST https://api.ebay.com/post-order/v2/casemanagement/{caseId}/issue_refund

i have also ebay auth token as Authorization in header.

When it run into postman by using above details then Api throws "Page not responding"

I also developed Api call in C#

My code details

/ Set issue to return url string returnUrl = "https://api.ebay.com/post-order/v2/casemanagement/" + CaseId + "/issue_refund"; HttpWebRequest returnRequest = (HttpWebRequest)WebRequest.Create(returnUrl); returnRequest.Method = "POST"; // Set EbayToken returnRequest.Headers.Add("authorization", eBayToken); //returnRequest.Headers.Add("authorization", eBayToken); using (HttpWebResponse returnResponse = (HttpWebResponse)returnRequest.GetResponse()) { using (Stream returnStream = returnResponse.GetResponseStream()) { using (StreamReader returnReader = new StreamReader(returnStream)) { // Get Api Response string returnResponseText = returnReader.ReadToEnd(); } } } Please guide me how to "IssueCaseRefund" using ebay post order Api

Open in new window

Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

A lot to go thru, but that should get you most of the way:

Also note this is using https://www.newtonsoft.com/json


  string returnUrl = "https://api.ebay.com/post-order/v2/casemanagement/" + CaseId + "/issue_refund";

HttpWebRequest returnRequest = (HttpWebRequest)WebRequest.Create(returnUrl); returnRequest.Method = "POST"; 
// Set EbayToken 
// ADD "Bearer"
   returnRequest.Headers.Add("authorization", "Bearer " + eBayToken); 

//Specify JSON
   returnRequest.Accept = "application/json";
    returnRequest.ContentType = "application/json";

    //use TLS 1.2
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

// if you needed to write the additional data you could create a class 
// ResponseAuthenticate ra = new ResponseAuthenticate()
//   string jSon = JsonConvert.SerializeObject(ra, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

/*  write data if needed 
  Byte[] data = Encoding.UTF8.GetBytes(jSon);
            request.ContentLength = data.Length;

            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }
*/

            try
            {

                WebResponse response = (HttpWebResponse)request.GetResponse();

                string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                ResponseRefund rr = JsonConvert.DeserializeObject<ResponseRefund>(responseString);
            
            }
            catch (WebException ex)
            {
                Result = "FAILURE";
                return HandleError(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
     }


   private static string HandleError(WebException ex, string placeholder)
        {
                
            string responseString = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
            Errors err = JsonConvert.DeserializeObject<Errors>(responseString);

            string errors = "";

            foreach (Error er in err.errors)
                errors += String.Format("Error Code: {0}, Description: {1};", er.error_code, er.description);


            return String.Format("In {0} - Error(s) - {1}", placeholder, errors);
        }
     }

    class ResponseRefund 
    {
       ResponseRefundResult refundResult;
    }
    
   class ResponseRefundResult
   {
      string refundSource;
      string refundStatus;
   }

/*  SAMPLE CLASS
    class ResponseAuthenticate
    {
        [JsonProperty("access_token")]
        public string accessToken;

        public string scope;

        [JsonProperty("token_type")]
        public string tokenType;

        [JsonProperty("expires_in")]
        public string expires;

    }
*/

Open in new window

Avatar of Ria jain
Ria jain

ASKER

I am trying the same way you suggested in code.Getting "Page Not Responding" issue . I have taken TLS code lines from your code and same response.


                           string returnUrl = "https://api.ebay.com/post-order/v2/casemanagement/" + CaseId + "/issue_refund";
                            HttpWebRequest returnRequest = (HttpWebRequest)WebRequest.Create(returnUrl);
                            returnRequest.Method = "POST";
                
           
                // Set EbayToken
                            returnRequest.Headers.Add("authorization", "Bearer " + eBayToken);
                
            //EDITED THIS PART from your code
//--------------------------------------------------------------
                            ServicePointManager.Expect100Continue = true;
                            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
//--------------------------------------------------------------

                            using (HttpWebResponse returnResponse = (HttpWebResponse)returnRequest.GetResponse())
                            {
                                using (Stream returnStream = returnResponse.GetResponseStream())
                                {
                                    using (StreamReader returnReader = new StreamReader(returnStream))
                                    {
                                        // Get Api Response
                                        string returnResponseText = returnReader.ReadToEnd();
                                        // Deserialize api response
                                        JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                                        refundResult obj = jsonSerializer.Deserialize<refundResult>(returnResponseText);
                                    }
                                }
                            }

Open in new window

Capture.JPG
Can you verify the CaseId is correct?  

Also I would add these headers:
returnRequest.Accept = "application/json";
    returnRequest.ContentType = "application/json";

Open in new window

Yes case ids are live from production account. With almost all types of status i can have to test.

I am getting response for only case ids having escalation or closed after escalations, using ebay post -order/casemanagement api

we tested with or without these headers you suggested.
That's a function of ebay then - which would make sense given you're trying to issue a refund.

So please confirm you're using a valid case ID.  Beyond that a page not responding can also be an issue with the server side of things.  

Someone else also reported this in their forums:
https://www.experts-exchange.com/questions/29089488/Ebay-Post-Order-API-Not-Working.html?anchor=a42501900¬ificationFollowed=205255086&anchorAnswerId=42501900#a42501900

Can you try the /v1/ api?
I have not tried v1 api for refund. I will give it a try and keep you posted.

I can confirm that ebay caseid are proper.Using that we can check case escalation information and status using same post-order api, But can't refund.
HI,

Try to code using v1 api and it seems getting response. Getting fail response from ebay api against closed escalated case.

Don't have open escalation so waiting for that to test refund.

Still wondering why not v2 APi working.
I would follow up with ebay but that would definitely indicate that it's a server side issue.  There could be a bug they're not aware of or it isn't fully published yet?
here is the update with ebay v1.

Ebay API v1 seems resp[onding but still no success with refund.

Ebay v1 code and Response :

// Set issue to return url
   string endpointURL = "https://svcs.ebay.com/services/resolution/v1/ResolutionCaseManagementService";
// Set API endpoint URL for request
   HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpointURL);
// Set API service name for request
   request.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "ResolutionCaseManagementService");
// Set API method for request
   request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "issueFullRefund");
// Set API ebay authorize token  for request
   request.Headers.Add("X-EBAY-SOA-SECURITY-TOKEN", eBayToken);
   request.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");
   request.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");
   request.Method = "POST";
   using (StreamWriter streamWriter = new StreamWriter(request.GetRequestStream()))
    {
                                // Request for full refund
     string requestFilterString = "<?xml version=\"1.0\" encoding=\"utf - 8\"?>";
     requestFilterString += "<issueFullRefundRequest xmlns=\"http://www.ebay.com/marketplace/resolution/v1/services\">";
     requestFilterString += "<caseId>";
     requestFilterString += "<id>"+ CaseDetails.CaseId + "</id>";
     requestFilterString += "<type>" + CaseDetails.CaseType + "</type>";
     requestFilterString += "</caseId>";
     requestFilterString += "<comments>Return from SA</comments>";
     requestFilterString += "</issueFullRefundRequest>";
     streamWriter.Write(requestFilterString);
     streamWriter.Flush();
    }
     //returnRequest.Headers.Add("authorization", eBayToken);
     ServicePointManager.Expect100Continue = true;
     ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
      using (HttpWebResponse returnResponse = (HttpWebResponse)request.GetResponse())
        {
          using (Stream returnStream = returnResponse.GetResponseStream())
            {
            using (StreamReader returnReader = new StreamReader(returnStream))
               {
                   // Get Api Response
                   string returnResponseText = returnReader.ReadToEnd();
                }

Open in new window


 When i have execute this code Api throw response "User is not eligible to execute this option based on current case status."

       <?xml version='1.0' encoding='UTF-8'?>

		<issueFullRefundResponse xmlns="http://www.ebay.com/marketplace/resolution/v1/services">
    
                    <ack>Failure</ack>
    
                    <errorMessage>
        
                         <error>
            
                         <errorId>1505</errorId>
 
                         <domain>Marketplace</domain>

                         <severity>Error</severity>
			 <category>Application</category>

		         <message>User is not eligible to execute this option based on current case status.</message>
 
           	         <subdomain>Resolution</subdomain>
		         </error>
    
		   </errorMessage>
    
                  <version>1.3.0</version>
    
                  <timestamp>2018-03-19T07:28:58.021Z</timestamp>

            </issueFullRefundResponse>

Open in new window

That would seem to indicate that it is working correctly.  Not sure when you can issue a refund, more digging would be needed but it would seem to be a workflow issue at that point and not an API issue per se.
I get your point. Nothing mention in ebay docs about when refund can be issue .

If we see the flow inside ebay system. You can refund against the escalated case.So based on that we assumed that refund can be issued against escalated cases using API.
Just found this in the documentation https://developer.ebay.com/devzone/post-order/concepts/usageguide.html:

API Restrictions
The Post-Order API is initially only available for transactions occurring on the US, UK, Germany, Australia, and Canada (English and French version) sites
Not sure what site your transactions are working on but can you confirm?
It may be time to contact eBay directly via their support channels: https://developer.ebay.com/signin?return_to=%2Fmy%2Fsupport%2Ftickets
I am working on Normal ebay US account so its available for that account.

Let me try to contact with ebay paid support that seems only solution to me as last resort.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.