Developers Program

Obtain Message object in Java SDK

Published: April 14 2011, 9:13:00 PMยทUpdated: August 19 2022, 2:56:14 PM

Products

Answer

Message field that is returned by the Add/Revise/Relist calls contains listing hints, policy violation explanations, or other details. To be able to handle the Message field and display it to your seller will help them to take an appropriate action accordingly in a timely manner.

Message is the property of AbstractResponseType object, when use wrapper class like ReviseFixedPriceItemCall in Java SDK to make the AddItem family of calls, you can retreive it via getResponseObject() method as below:

import com.ebay.sdk.*;
import com.ebay.sdk.call.ReviseFixedPriceItemCall;
import com.ebay.soap.eBLBaseComponents.*;


public class ReviseFixedPriceItem {

static String messageValue;
public static void reviseFixedPriceItem(){

String newdescription="YOUR NEW DESRIPTION";
ApiContext apiContext = new ApiContext(); // Create a new APIContext Object

// set Api Token to access eBay Api Server
ApiCredential cred = apiContext.getApiCredential();
cred.seteBayToken("YourToken");

apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");// Pointing to SandBox for testing

// Enable logging of SOAP requests and responses. Recommended only for testing/debugging.
apiContext.getApiLogging().setLogSOAPMessages(true);

apiContext.setSite(SiteCodeType.US); // Set site to US

ReviseFixedPriceItemCall rfp = new ReviseFixedPriceItemCall(apiContext);

ItemType item = new ItemType();
item.setDescription(newdescription);

rfp.setItemToBeRevised(item);
try {
rfp.reviseFixedPriceItem();
//you need to surface the message to sellers if the Message object is returned
if (rfp.getResponseObject().getMessage() !=null){
messageValue=rfp.getResponseObject().getMessage();
// surface the message to your seller
}

} catch (ApiException apiE) {
apiE.printStackTrace();
} catch (SdkException sdkE) {
sdkE.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

}
public static void main(String[] args) {
reviseFixedPriceItem();
}

}

How well did this answer your question?