<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Strange bug with REST API</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/1504/strange-bug-with-rest-api</link><description>Hello All, I had an issue this morning while working with my REST API. If I tried to use the JavaScript app.api.call function, as documented here Documentation Class: Api , I ran into the error: &amp;quot;no method&amp;quot; with the message &amp;quot;Could not find a route with</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Strange bug with REST API</title><link>https://sugarclub.sugarcrm.com/thread/6099?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2019 18:33:32 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:cf76c9aa-e3c6-4d50-9562-876efefd6ac1</guid><dc:creator>Josh Wright</dc:creator><description>&lt;p&gt;Oh no, I figured it out as I replied above. Apparently if you don&amp;#39;t use&lt;/p&gt;&lt;p&gt;r&lt;span style="color:#777777;background-color:#f9f9f9;font-weight:200;"&gt;ead, create, update, delete&amp;nbsp;&lt;/span&gt;&lt;span style="color:#777777;background-color:#f9f9f9;font-weight:200;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;In Place of&lt;/p&gt;&lt;p&gt;&lt;span style="color:#777777;background-color:#f9f9f9;font-weight:200;"&gt;GET, POST, PUT, DELETE.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Then app.api.call will actually only send GET requests instead of POST requests (Despite using &amp;#39;POST&amp;#39; as the first argument). I assumed (wrongly) that Sugar would stick to the same CRUD commands that have been standardized and used for a long time, instead of abstracting&amp;nbsp;them away&amp;nbsp;(for what purpose I have no idea).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Strange bug with REST API</title><link>https://sugarclub.sugarcrm.com/thread/6098?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2019 17:24:00 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:1d2382e3-5761-4dfd-8453-322f2dead63f</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;If you are calling the api from within the application, the user is authenticated and already has a token, you will not need to request another or refresh it. The app takes care of that.&lt;/p&gt;&lt;p&gt;I believe you should use POST to create a new record, PUT to update an existing one. Clearly if you are updating it will need the id of the record to update. But if you are creating a new one, you won&amp;#39;t have an id until after it is created.&lt;/p&gt;&lt;p&gt;Perhaps it would help if you could share your custom API. I totally understand if you can&amp;#39;t.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Francesca&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Strange bug with REST API</title><link>https://sugarclub.sugarcrm.com/thread/6096?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2019 17:00:01 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:b0c2d623-d5d9-482a-8aa5-00ed02db8be2</guid><dc:creator>Josh Wright</dc:creator><description>&lt;p&gt;I actually found the issue. Apparently the app.api.Call method actually remaps &amp;#39;POST&amp;#39; as &amp;#39;update&amp;#39;. My fault, but I don&amp;#39;t really understand why this would be done instead of just using the proper http methods. Why add another layer of confusion? I find myself asking this question a lot when dealing with Sugar. Thank you for trying.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Strange bug with REST API</title><link>https://sugarclub.sugarcrm.com/thread/6097?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2019 14:55:40 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:6d74817e-69ef-4b50-9b53-f663aafc6794</guid><dc:creator>Josh Wright</dc:creator><description>&lt;p&gt;I tried both&amp;nbsp;&lt;/p&gt;&lt;p&gt;var app_url = app.api.buildURL(&amp;#39;/&amp;lt;endpoint name&amp;gt;/&amp;lt;endpoint method&amp;gt;?=&amp;#39; + &amp;lt;put querystring here&amp;gt;);&lt;/p&gt;&lt;p&gt;as well as&lt;/p&gt;&lt;p&gt;var app_url = app.api.buildURL(&lt;span&gt;&amp;lt;endpoint name&amp;gt;,&amp;nbsp;&amp;lt;endpoint method&amp;gt;&lt;/span&gt;);&lt;/p&gt;&lt;p&gt;I read in the documentation&amp;nbsp;&lt;span style="color:#777777;background-color:#fcfcfc;font-weight:200;"&gt;The&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code style="color:#c7254e;background-color:#fcfcfc;border:none;font-weight:200;padding:2px 4px;"&gt;attributes&lt;/code&gt;&lt;span style="color:#777777;background-color:#fcfcfc;font-weight:200;"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;hash must contain&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code style="color:#c7254e;background-color:#fcfcfc;border:none;font-weight:200;padding:2px 4px;"&gt;id&lt;/code&gt;&lt;span style="color:#777777;background-color:#fcfcfc;font-weight:200;"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;of the resource being actioned upon for record CRUD and&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code style="color:#c7254e;background-color:#fcfcfc;border:none;font-weight:200;padding:2px 4px;"&gt;relatedId&lt;/code&gt;&lt;span style="color:#777777;background-color:#fcfcfc;font-weight:200;"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;if the URL is build for relationship CRUD. I don&amp;#39;t really have those as it is a custom endpoint.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;and wasn&amp;#39;t sure whether I needed those for my use case. I was using query strings for now during testing.&lt;/p&gt;&lt;p&gt;Quick question from the original post though, somewhat related. If I do end up getting this to work through Sugar&amp;#39;s method of api calling, will it bypass the authentication requirement of getting tokens and refreshing them? (Instead, using the user&amp;#39;s own base token).&amp;nbsp;&lt;span&gt;I honestly feel a lot more comfortable using JavaScript&amp;#39;s&amp;nbsp;&lt;/span&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API" rel="nofollow" style="color:#2989c5;text-decoration:none;" target="_blank"&gt;Fetch API&lt;/a&gt;, it&amp;#39;s a lot better documented and usable anywhere and not just within an obscure platform.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Strange bug with REST API</title><link>https://sugarclub.sugarcrm.com/thread/6095?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2019 14:43:20 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:e24b6d6d-3fba-40a4-9896-1b5f0aee15d6</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;When calling the api from your javascript are you building the url as described here?&lt;/p&gt;&lt;p&gt;&lt;a href="https://sugarcrm.github.io/ventana/Api.html#buildURL__anchor" rel="nofollow" target="_blank"&gt;Documentation Class: Api&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;e.g.&amp;nbsp;&lt;/p&gt;&lt;pre class="language-javascript line-numbers"&gt;&lt;code&gt;&lt;span class="keyword token"&gt;var&lt;/span&gt; url &lt;span class="operator token"&gt;=&lt;/span&gt; app&lt;span class="punctuation token"&gt;.&lt;/span&gt;api&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="token function"&gt;buildURL&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;&lt;span class="string token"&gt;&amp;quot;Contacts&amp;quot;&lt;/span&gt;&lt;span class="punctuation token"&gt;,&lt;/span&gt; &lt;span class="string token"&gt;&amp;quot;duplicateCheck&amp;quot;&lt;/span&gt;&lt;span class="punctuation token"&gt;,&lt;/span&gt; &lt;span class="keyword token"&gt;null&lt;/span&gt;&lt;span class="punctuation token"&gt;,&lt;/span&gt; &lt;span class="punctuation token"&gt;{&lt;/span&gt;&lt;span class="punctuation token"&gt;}&lt;/span&gt;&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;;&lt;/span&gt;&lt;span class="line-numbers-rows"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;e.g. I have custom a GET api that returns currency based on country:&lt;/p&gt;&lt;pre class="language-javascript line-numbers"&gt;&lt;code&gt;&lt;span class="keyword token"&gt;var&lt;/span&gt; url &lt;span class="operator token"&gt;=&lt;/span&gt; app&lt;span class="punctuation token"&gt;.&lt;/span&gt;api&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="token function"&gt;buildURL&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;&lt;span class="string token"&gt;&amp;#39;/ERPCurrencyLookup/&amp;#39;&lt;/span&gt; &lt;span class="operator token"&gt;+&lt;/span&gt; address_country&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;;&lt;/span&gt;&lt;span class="line-numbers-rows"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p class=""&gt;&lt;span class=""&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;FrancescaS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>