Unable to create company in Non Mint org using apigee_nonmint_company module in Developer Portal

Company creation fails in developer portal using apigee_nonmint_company module in developer portal,

When you create a company in Developer portal, It fails without any error. Steps to reproduce above issues,

Click on My Apps -> Click on Manage Companies / Invitations -> Click Create Company-> Enter Company Name-> Click Save Company.

When we take a look at recent log message below error is seen,

>>>>>>>>
DELETE /v1/o/{org}/companies/{xxx}/developers/{xxxx} HTTP/1.1
Host: api.enterprise.apigee.com
accept: application/json; charset=utf-8
User-Agent: DevPortal/17.03.27.00 Guzzle/3.9.3 curl/7.40.0 PHP/5.5.24
Authorization: Basic [**masked**]
Referer: xxxx
X-NewRelic-ID: VQIGV1ZUCRADVlBaAwADXg==
X-NewRelic-Transaction: PxQCVlJTAAsCVAJSU1QEVwcGFB8EBw8RVU4aVw8MBAoLVwkCAQVWUVVVAENKQQtWB1RYWw4CFTs=
Content-Length: 0


<<<<<<<<
HTTP/1.1 404 Not Found
Content-Type: application/json
Date: Fri, 26 May 2017 23:20:23 GMT
Server: Apigee LB
Content-Length: 156
Connection: keep-alive

Any idea ?

Solved Solved
2 9 838
1 ACCEPTED SOLUTION

It's due to a bug in Management PHP SDK, Edge SDK is trying to delete a developer who didn't exist in the company,

Take a look at code here in line no 375 , As you can see a workaround has implemented to bypass a bug in Apigee Edge monetization, When that bug was fixed, It introduce a new bug in developer portal which tries to delete a non exist developer in company.

You can override above method in your custom module to have a temporary fix, See attached custom module which should fix above issue.

<?php

require_once drupal_get_path('profile', 'apigee') . '/libraries/mgmt-api-php-sdk/vendor/autoload.php';

/**
 * Abstracts the Company object in the Management API and allows clients to
 * manipulate it.
 *
 * Note: at this time Companies do not support paging.
 *
 * @author djohnson
 */
class CompanyNonMint extends Apigee\ManagementAPI\Company {

    /**
     * Adds or updates a developer (and the dev's role) on the Edge server.
     *
     * When updating an existing developer, specify both the developer's email
     * and role.
     *
     * @param string $dev_email
     * @param string $role
     * @param null|string $company_name
     * @throws \Apigee\Exceptions\ParameterException
     */
    public function updateNonMintDeveloper($dev_email, $role = 'developer', $company_name = null)
    {
        $company_name = $company_name;
        if (empty($company_name)) {
            throw new ParameterException('No company name given.');
        }

        $payload = array('developer' => array(
            array(
                'email' => $dev_email,
                'role' => $role)
        ));
        $url = rawurlencode($company_name) . '/developers';
        $this->post($url, $payload);
    }
} 

Custom module with updated code below,

apigee-nonmint-company.zip

Hope it helps someone looking to fix above issue until fix is available in portal release.

View solution in original post

9 REPLIES 9

It's due to a bug in Management PHP SDK, Edge SDK is trying to delete a developer who didn't exist in the company,

Take a look at code here in line no 375 , As you can see a workaround has implemented to bypass a bug in Apigee Edge monetization, When that bug was fixed, It introduce a new bug in developer portal which tries to delete a non exist developer in company.

You can override above method in your custom module to have a temporary fix, See attached custom module which should fix above issue.

<?php

require_once drupal_get_path('profile', 'apigee') . '/libraries/mgmt-api-php-sdk/vendor/autoload.php';

/**
 * Abstracts the Company object in the Management API and allows clients to
 * manipulate it.
 *
 * Note: at this time Companies do not support paging.
 *
 * @author djohnson
 */
class CompanyNonMint extends Apigee\ManagementAPI\Company {

    /**
     * Adds or updates a developer (and the dev's role) on the Edge server.
     *
     * When updating an existing developer, specify both the developer's email
     * and role.
     *
     * @param string $dev_email
     * @param string $role
     * @param null|string $company_name
     * @throws \Apigee\Exceptions\ParameterException
     */
    public function updateNonMintDeveloper($dev_email, $role = 'developer', $company_name = null)
    {
        $company_name = $company_name;
        if (empty($company_name)) {
            throw new ParameterException('No company name given.');
        }

        $payload = array('developer' => array(
            array(
                'email' => $dev_email,
                'role' => $role)
        ));
        $url = rawurlencode($company_name) . '/developers';
        $this->post($url, $payload);
    }
} 

Custom module with updated code below,

apigee-nonmint-company.zip

Hope it helps someone looking to fix above issue until fix is available in portal release.

Anil, very clear answer... Just one problem.

When I click through to the apigee-nonmint-company repo, there's no README.

So what does this thing do?

What problem does it solve?

When would I use it?

@Dchiesa1 , Above module can be used in non mint enabled org to work with companies, company developers, company apps concepts in Developer Portal. It helps you tie apps to companies instead of developers.

We have seen above issue multiple times lately & support team requested for an article in community till we have a fix in core.

@Dchiesa1 The setup instructions and usecase for this module can be found in the README file here

+1 , Awesome, Thank you @rrai. Welcome to Apigee Communtiy !

Thanks @rrai !

This is an older issue but I found I thought I was having a similar problem - I was trying out the Apigee Nonmint Companies module locally, but when I created a new company, no new company was being created. When I looked in the logs I saw lots of errors about 'developer noreply@apigee.com not found' so I tried creating a dummy developer in my Org on Edge with the email 'noreply@apigee.com'. This solved my issue.

Is there any equivalent drupal 8 module available for apigee-nonmint-company?