Jump to content


Photo

Opportunity Create Api Help

Opportunity Api Create

  • Please log in to reply
3 replies to this topic

#1 brobin

brobin

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 10 October 2013 - 09:42 AM

Hi I've been playing around with Zurmo and I think it looks really great!

 

I'm trying to get APIs to work, so I've looked at the documentation and pretty much copied the code from there, but i always end up with this response:

{"status":"FAILURE","data":null,"message":"Please provide data.","errors":null}

 

The following is my code, this is for Creating an Opportunity:

<?php
require '/var/www/html/zurmo/app/protected/modules/api/components/ApiRestHelper.php';
$url = 'http://(my_site_here)/zurmo/app/index.php/opportunities/opportunity/api/create';
$method = 'POST';
$headers = array (
		'Accept: application/json',
		'ZURMO_SESSION_ID: ' . 'b6kqatgqqgm1i3sftag9fj7ng6',
		'ZURMO_TOKEN: ' . '995f8f0500a34f70b976f75223167a2c',
		'ZURMO_API_REQUEST_TYPE: REST' 
);

$data['name'] 				="Michael";
$data['closeDate']			="2014-04-03";
$data['probability']			="10";
$data['description']			="Opportunity description";
$data['source']['value']		="Outbound";
$data['account']['id']			="2";
$data['amount']['value']		="100";
$data['amount']['currency']['id']	= "1";
$data['stage']['value']			= "Negotiating";
$data['owner']['id']			="1";
$data['owner']['username']		="super";
$data['createdByUser']['id']		="1";
$data['createdByUser']['username']	="super";
$data['modifiedByUser']['id']		="1";
$data['modifiedByUser']['username']	="super";



$response = ApiRestHelper::createApiCall ( $url, $method, $headers, $data );
print_r ($response);
?>

Hopefully someone knows an answer to this!



#2 spydon

spydon

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 23 October 2013 - 08:07 AM

We have the same problem with creating a new note.
We are using the same headers as Brobin and the following as payload:

{"data":{"description":"BAJSKAKA","occurredOnDateTime":"2013-10-23 05:10:19","owner":{"id":1,"username":"super"}}}

It results in the same response as the one Brobin got.

{"status":"FAILURE","data":null,"message":"Please provide data.","errors":null}

We sniffed our own packages and the json is sent properly to the server.

 

We tried to find where it stopped working and printed the value of

$params = Yii::app()->apiRequest->getParams();

from

public_html/app/protected/modules/zurmo/components/ZurmoModuleApiController.php Row 110

but it was always empty.
Any clues what we are doing wrong?



#3 spydon

spydon

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 24 October 2013 - 12:50 AM

We do the same call towards http://demo.zurmo.co...e/app/index.php which we can authenticate with super super towards, but we still get the same answer. So either there is something wrong with our JSON data or this is a major bug.

Can anybody confirm that our JSON payload is correct?



#4 spydon

spydon

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 24 October 2013 - 04:05 AM

Sorry to hijack your thread, our problem was not the same as yours.

Apparently Zurmo does not accept json, it only returns it.
Zurmo only accepts application/x-www-form-urlencoded for some reason.
Seems very weird to me. This should definitely be made clearer in the documentation, we spent two days trying to figure out why our code didn't work.
Any explanation from the developers why it has been done this way?

If anybody else stumbles across the same problem there might be an answer to our stack overflow question at that point: http://stackoverflow...n-to-urlencoded







Also tagged with one or more of these keywords: Opportunity, Api, Create

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users