Skip to main content
Published: August 21 2006, 9:30:00 AMUpdated: November 28 2020, 2:26:49 PM

Why GetCharitiesCall.getCharityID() returns null 

Summary

You are getting null because the CharityID property is an input param for GetCharties API call and it does not exist in the GetCharitiesResponse. The Charity[attribute id ] is the ID property that represents an unique identification of  a Charity organization in the GetCharitiesResponse. So you need to use getId() method to retrieve
the charity Id. The CharityID tag in GetCharitiesRequest is as <Charity id="3856"> and the the Charity[attribute id ] tag in the GetCharitiesResponse is as <Charity id= "3856">.

Please keep in mind that the two IDs basiclly refer to the same property: an unique identification for a Charity orgnizationin .


Detailed Description

The follow code snippet demonstrates using the two IDs in JAVA SDK:

     GetCharitiesCall api = new GetCharitiesCall(apiContext);
     GetCharitiesRequestType req = new GetCharitiesRequestType();
      req.setSite(SiteCodeType.US);
      req.setIncludeDescription(new Boolean(false));
      req.setCharityRegion(new Integer(7));
      req.setQuery("child");
      req.setCharityID("3856");
      api.setOverrideRequest(req);
      // Make API call.
     try{
        api.getCharities();
     }catch(Exception e){
        e.toString();        
     }
       
     CharityInfoType[] charities = api.getReturnedCharities();
     for (int i =0; i<charities.length; i++){
         CharityInfoType theCharityInfo = charities[i];
         theCharityInfo.getId();
         System.out.println(" charityId :" + theCharityInfo.getId());          
     }

 The code snippet  generates the GetCharitiesRequest and GetCharitiesResponse SOAP xml as below:
 
 <?xml version="1.0" encoding="UTF-8"?>
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
   <ebl:RequesterCredentials soapenv:mustUnderstand="0" xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
    <ebl:eBayAuthToken xmlns:ebl="urn:ebay:apis:eBLBaseComponents">YOUR TOKEN</ebl:eBayAuthToken>
   </ebl:RequesterCredentials>
  </soapenv:Header>
  <soapenv:Body>
   <GetCharitiesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
    <ErrorLanguage>en_US</ErrorLanguage>
    <Version>467</Version>
    <CharityID>3856</CharityID>
    <Query>child</Query>
    <CharityRegion>7</CharityRegion>
    <IncludeDescription>false</IncludeDescription>
   </GetCharitiesRequest>
  </soapenv:Body>
 </soapenv:Envelope>
 
  Response Message:

<?xml version="1.0" encoding="UTF-8"?>
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
   <GetCharitiesResponse xmlns="urn:ebay:apis:eBLBaseComponents">
    <Timestamp>2006-08-22T021:45:22.281Z</Timestamp>
    <Ack>Success</Ack>
    <Version>473</Version>
    <Build>e473_core_Bundled_3402943_R1</Build>
    <Charity id="3856">
     <Name>Starlight Starbright Children's Foundation</Name>
     <Mission>The Starlight Starbright Children's Foundation is dedicated to brightening the lives of seriously ill children and their families through imaginative, resourceful programs and multimedia projects that uplift their spirits to help transcend pain and fear.</Mission>
     <LogoURL>http://missionfish.ibs.aol.com/logos/1097777622389.gif</LogoURL>
     <CharityRegion>7</CharityRegion>
     <CharityDomain>2</CharityDomain>
    </Charity>
   </GetCharitiesResponse>
  </soapenv:Body>
 </soapenv:Envelope>


Version Info

The code example above was based on the versions specified below:

API Schema Version 473
Java SDK Version javasdk v467.0 point release


Additional Resources

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