AnsweredAssumed Answered

API call strips everything after the '&'

Question asked by Francesca Shiekh on Aug 24, 2015
Latest reply on Sep 22, 2015 by Francesca Shiekh
I have a call to a custom API.
I url encode the value before calling the API but everything after the '&' in the value is stripped.
I am passing an account name whose value is "School of Mathematics Science & Tech"

In the view (see code below)

console.log(value) shows the url encoded value:

School%20of%20Mathematics%20Science%20%26%20Tech

console.log(url) still has the url encoded value

rest/v10/buildSpikey/from/account/with/School%20of%20Mathematics%20Science%20%26%20Tech

But in the API the argument has lost everything from the & on: 

$GLOBALS['log']->fatal($args) outputs:

(

                 

    [__sugar_url] => v10/buildSpikey/from/account/with/School of Mathematics Science 

 

    [Tech] => 

 

    [from_what] => account

 

    [val] => School of Mathematics Science 

 

)

Clearly I am missing something on HOW to pass values to the API.


the View:

  buildSpikeyURL: function(from, value, self){

                 

    if(typeof(value) !== 'undefined' && typeof(from) !== 'undefined'){

 

      var url = app.api.buildURL('buildSpikey/from/'+from+'/with/'+value),

console.log(value);

 

        resource_name = 'bizi-license-'+value,

 

        link = value.replace(';',' '),

 

        teaser = 'Reference based on ' +from,

 

        Biziurl = false,

 

        color = 'green';

console.log(url);

                 

      if(from == 'license') color = 'red';

 

      App.api.call('GET', url, '', {

 

        success:_.bind(function(o){

 

          //console.log(o);

 

          Biziurl = o;

 

          //build resource

 

          self.resources[resource_name]={

 

           'color':color,

 

           'icon':'icon-asterisk',

 

           'link':link,

 

           'teaser': teaser,

 

           'url':Biziurl,

 

          };

 

          $('ul.dashlet-licenses').closest('.dashlet').css("overflow","scroll");

 

          self._super('_renderHtml');

 

        }, this),

 

        error: _.bind(function(o){

 

          console.log('Could not build Spikey');

 

          console.log(o);

 

        }, this),

 

      });

 

    }

 

  },

  _renderHtml: function() {

                 

    var self = this,

....


The API:


<?php

class buildSpikeyApi extends SugarApi

{

  public function registerApiRest() {

    return array(

      'buildSpikey' => array(

        'reqType' => 'GET',

        'path' => array('buildSpikey', 'from', '?', 'with' ,'?'),

        'pathVars' => array('','','from_what','','val'),

        'method' => 'buildSpikey',

        'shortHelp' => 'CustomWR: some details here',

        'longHelp' => '',

      ),

    );

  }

  function buildSpikey($api, $args)

  {

    $GLOBALS['log']->fatal($args);

....

Thank you
FrancescaS

Outcomes