Skip to main content
edited title
Link
Ajwad Syed
  • 1.6k
  • 30
  • 63

Mangento2 Swagger sends request with index.php/rest/all Difference in URL which is differentresponse from URL in Postman?magento swagger and postman Magento 2

added 9 characters in body
Source Link
Ajwad Syed
  • 1.6k
  • 30
  • 63

I have custom API in which I am retrieving customer balance as:

use Magento\CustomerBalance\Model\BalanceFactory; ........................ ........................ $model = $this->balanceFactory->create()->setCustomerId($customerId)->loadByCustomer(); $customerBalance = $model->getAmount(); 

In postman request is send as:

http://127.0.0.1/rest/V1/mymodule/request/R1

and output is correct loggedinlogged in customer balance.

But when I test same API in Magento swagger UI, here the Curl appears is:

curl -X POST "http://127.0.0.1/index.php/rest/all/V1/mymodule/request/R1" -H "accept: application/json" -H "Authorization: Bearer nbvkrjkewuiu398hds"

which has extra index.php/rest/all/

and from response the customer balance is shown as 0 always.

What is the reason of different behavioroutput on testing same API in Default Swagger and then in Postman ?

Any help will be highly appreciated!

I have custom API in which I am retrieving customer balance as:

use Magento\CustomerBalance\Model\BalanceFactory; ........................ ........................ $model = $this->balanceFactory->create()->setCustomerId($customerId)->loadByCustomer(); $customerBalance = $model->getAmount(); 

In postman request is send as:

http://127.0.0.1/rest/V1/mymodule/request/R1

and output is correct loggedin customer balance.

But when I test same API in Magento swagger UI, here the Curl appears is:

curl -X POST "http://127.0.0.1/index.php/rest/all/V1/mymodule/request/R1" -H "accept: application/json" -H "Authorization: Bearer nbvkrjkewuiu398hds"

which has extra index.php/rest/all/

and from response the customer balance is shown as 0 always.

What is the reason of different behavior on testing same API in Default Swagger and Postman ?

Any help will be highly appreciated!

I have custom API in which I am retrieving customer balance as:

use Magento\CustomerBalance\Model\BalanceFactory; ........................ ........................ $model = $this->balanceFactory->create()->setCustomerId($customerId)->loadByCustomer(); $customerBalance = $model->getAmount(); 

In postman request is send as:

http://127.0.0.1/rest/V1/mymodule/request/R1

and output is correct logged in customer balance.

But when I test same API in Magento swagger UI, here the Curl appears is:

curl -X POST "http://127.0.0.1/index.php/rest/all/V1/mymodule/request/R1" -H "accept: application/json" -H "Authorization: Bearer nbvkrjkewuiu398hds"

which has extra index.php/rest/all/

and from response the customer balance is shown as 0 always.

What is the reason of different output on testing same API in Default Swagger and then in Postman ?

Any help will be highly appreciated!

Source Link
Ajwad Syed
  • 1.6k
  • 30
  • 63

Mangento2 Swagger sends request with index.php/rest/all in URL which is different from URL in Postman?

I have custom API in which I am retrieving customer balance as:

use Magento\CustomerBalance\Model\BalanceFactory; ........................ ........................ $model = $this->balanceFactory->create()->setCustomerId($customerId)->loadByCustomer(); $customerBalance = $model->getAmount(); 

In postman request is send as:

http://127.0.0.1/rest/V1/mymodule/request/R1

and output is correct loggedin customer balance.

But when I test same API in Magento swagger UI, here the Curl appears is:

curl -X POST "http://127.0.0.1/index.php/rest/all/V1/mymodule/request/R1" -H "accept: application/json" -H "Authorization: Bearer nbvkrjkewuiu398hds"

which has extra index.php/rest/all/

and from response the customer balance is shown as 0 always.

What is the reason of different behavior on testing same API in Default Swagger and Postman ?

Any help will be highly appreciated!