Questions tagged [webapi]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
11 votes
5 answers
32k views

Magento 2: How to return a JSON object from the API?

I'm trying to return a JSON object from one of my REST Models, something like this: { "settings": { "set1" : 2, "set2" : "key1" }, "extra": { "e1'" : { ...
Yehia A.Salam's user avatar
7 votes
1 answer
2k views

Best practice for returning errors in WebApi

So let's say I have a model, responding to my webapi calls, whats the best way to return an error to the api consumer. For example, in the code below, the second line query the category factory (di-ed)...
Yehia A.Salam's user avatar
4 votes
3 answers
2k views

Restricting access to anonymous web APIs

As given in the documentation here : http://devdocs.magento.com/guides/v2.0/rest/anonymous-api-security.html By default magento 2 only restrict Catalog, Store and CMS API from anonymous users. In a ...
manish_khot's user avatar
1 vote
1 answer
2k views

Extending Magento2 API

I have a very weird problem when trying to extend Magento2 API, I followed all the right steps, however im getting this syntax error when calling http://appfactory.loc/index.php/rest/V1/appfactory/...
Yehia A.Salam's user avatar
7 votes
1 answer
3k views

How do I consume the REST API in Magento 2, using AJAX with session-based authentication?

I am having issues successfully making an AJAX call to Magento 2 REST API endpoints, using session-based authentication. When I run the following javascript, I always receive a 401 (Not Authorized) ...
DrewK289's user avatar
  • 193
1 vote
1 answer
876 views

Magento 2: How can I store my original REST request in a file on the server?

I need to store my REST request within the file system - I have tried serializing the request object, but obviously the file size is quite a lot larger than the original. I have run a test that ...
BAF's user avatar
  • 719
2 votes
1 answer
8k views

Get list of ALL customers using REST API

I know I can get a specific customer by running: curl -X GET "http://127.0.0.1:32769/index.php/rest/V1/customers/2" -H "Authorization: Bearer token" How do I get the list of ALL customers?.. GET "...
user53473's user avatar
3 votes
1 answer
2k views

class [] does not exist for custom extension_attributes over webapi

I created a custom module to store the details of discount per items. I have a custom tables to store informations (quote items, order items, invoice items), and I use a extension attributes to link ...
eInyzant's user avatar
  • 321
1 vote
1 answer
3k views

How to add cutom customer attribute field to call rest api via create new customer

I have created a custom customer attribute(mobile_number) and set default value of customer create account. I added mobile number to customer_attribute: $customerSetup->addAttribute(Customer::...
Rajkumar .E's user avatar
  • 3,570
1 vote
0 answers
562 views

magento2 webapi authorization for admin users

In Magento 2.1.5 I cannot use webapi when I am logged in as admin user. I found this problem on my regular install and verified with a freh one: install magento 2.1.5 from composer repository log-in ...
skymeissner's user avatar
8 votes
3 answers
5k views

Magento2: How to check if request is from Web Service?

In Magento 1, We used to check as: if (Mage::getSingleton('api/server')->getAdapter() != null) { // request from Web-Service } How to check the same in Magento2? I didn't find any proper ...
MagePsycho's user avatar
  • 4,752
6 votes
3 answers
5k views

Magento 2 : Can the REST API return plain text?

I'm trying to make an endpoint for the Magento 2 Web API that simply returns plain text. Is this possible and if so, how? I'm currently trying this: webapi.xml: <route url="/V1/export/txt" ...
Giel Berkers's user avatar
  • 12.2k
4 votes
2 answers
4k views

Magento 2 : Social Login via Rest Api

I need to create a user account using social network via the API. I have created via native iOS application that hooks into magento 2 store API. However, I can not find a way to create an account ...
justacoder's user avatar
1 vote
1 answer
527 views

Magento 2 - WebApi /rest/V1/products/MY_SKU to create a new product error

I'm having troubles to PUT a product using the WebApi of M2 Im using this JSON: { "product": { "sku": "MY_SKU", "name": "My Product", "price": 20, "typeId": "simple", ...
Gianni Di Falco's user avatar
5 votes
2 answers
5k views

Magento 2 Customer login and forgot Password using Rest API

I need customer login and customer forgot password using Magento 2 API. Can you please help me. I was search but not getting any code from google.
Kartik Asodariya's user avatar
3 votes
1 answer
605 views

Unable to update custom column value of sales_order via Rest API

I want to trace records of all the completed orders which has been received from my Magento store to my ERP store through Rest API. I have created custom column through SQL query in sales_order so ...
Zeeshan Khuwaja's user avatar
1 vote
1 answer
2k views

Geting the available quantity for all products via REST API

How can I get the available quantity for all products via REST API?. Do I have to create a new module for this? What is the most efficient way to achieve this?
Kevin's user avatar
  • 139
2 votes
0 answers
83 views

How to implement paypal using Web Api on Magento2?

I am developing a mobile app using Magento2 Web Api. I am wondering how to implement Paypal for my mobile app. What versions of Paypal (express, etc.), is it used as an offline payment method?, do I ...
awavi's user avatar
  • 989
9 votes
3 answers
16k views

How to disable/enable a product programatically in Magento2?

I am trying to emulate the same behavior as when you use the admin panel to disable a product. I am trying to do something like this: $product = $this->productRepository->get($sku); $product-&...
awavi's user avatar
  • 989

1 2
3