Code Monkey home page Code Monkey logo

sdk-ebay-rest-negotiation's Issues

sendOfferToInterestedBuyers Response is not JSON data error

Hi mate , working on it recently , whatever I try this requests wont be successful , Response is not JSON data most commonly
whenever I use $res = $apiInstance->sendOfferToInterestedBuyers($this->ebayId,$offerRequest,$contentType); or $res = $apiInstance->sendOfferToInterestedBuyers($this->ebayId,$jsonString,$contentType); where $jsonString = json_encode($offerRequest);
What I missing , generated json file match ebay requirements perfectly and all required fields are there . Any hint would be much appreciated. Emil

public function send_Ebay_Offers($params){

$contentType = 'Content-type:application/json';
    //$offer_duration = ['unit'=>DAY,'value'=>2];
    //$offered_price  = ['currency'=>'GBP','value'=>$params['offerPrice']];
    $offered_price = ['value' => $params['offerPrice']];

    foreach ($params['listing_IDs'] as $listingID) {
        $offeredItems = [['listingID' => $listingID, 'price' => ['value' => $params['offerPrice']], 'quantity' => 1]];

        $offerRequest = new \macropage\SDKs\ebay\rest\negotiation\Model\CreateOffersRequest();
        $offerRequest->setAllowCounterOffer($params['allowCounterOffer']);
        $offerRequest->setMessage($params['message']);
        $offerRequest->setOfferedItems($offeredItems);

       // var_dump($offerRequest);die();
        //$jsonString = json_encode($offerRequest);
        $apiInstance = $this->apiInstance;
        
        try {
            $res = $apiInstance->sendOfferToInterestedBuyers($this->ebayId,$offerRequest,$contentType);
            print_r($res);
        } catch (\macropage\SDKs\ebay\rest\negotiation\ApiException $e) {
            // Capture and decode the error response
            $errorResponse = $e->getResponseBody(); // Get the raw response body
            $errorDetails = json_decode($errorResponse, true); // Decode JSON response to an associative array
            echo "EMIL Error: " . $errorDetails['errors'][0]['message'] ?? 'Unknown error';
        } catch (\Exception $e) {
            // Handle other exceptions (if any)
            echo "EMIL Exception: " . $e->getMessage();
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.