Web API (official plugin)

1 year ago
Referring to the API documentation (https://docs.nopcommerce.com/en/developer/web-api/index.html), and using Postman, I have the (latest version) API working successfully to authenticate and get a token, and the example {storeURL}/api-backend/Topic/GetById/:id also works fine.

However, I have had no luck with Postman with /api-backend/Product/AdjustInventory/{productId}

I am getting the following error:

{
    "errors": {
        "": [
            "Unexpected character encountered while parsing value: {. Path '', line 1, position 1."
        ],
        "quantityToChange": [
            "The quantityToChange field is required."
        ]
    },
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-ac6502ebef6c24356fef0f53de21196f-09a44a70153bba06-00"
}


I am POSTing to https://localhost:44369/api-backend/Product/AdjustInventory/1 with an appropriate Bearer token set, and I have the Body set to (raw/JSON):

{
    "quantityToChange": 1
}

No doubt I need to supply the quantityToChange in a different format (I tried as "form-data" but get "Unsupported Media Type"). It's probably a very simple solution,  but I have had no luck figuring it out! - any help very much appreciated.

Thank you.
1 year ago
Resolved - Re the above issue, the solution is to supply quantityToChange in the Postman 'Params' tab, and "" (literally) in the "Body" as raw JSON - works well (would be good to have a few more Postman examples as this particular command works differently to the two supplied examples in the API documentation).
1 year ago
It would be helpful if the backend API had a method to clear the cache.
1 year ago
Is there a pre build in the API which would allow to post data somewhere other than the sites database? For example another database?
1 year ago
CffNop wrote:
Is there a pre build in the API which would allow to post data somewhere other than the sites database? For example another database?

No, the API plugin works only with a website where it's installed (and an appropriate database)
1 year ago
Hello,
I just bought the WEB API plugin, but I find the installation instructions in the "installation_instructions.txt" a bit lacking. (See below).
I'm using a local Visual Studio solution with nopCommerce 4.50.
1) I know how to install plugins, but what should I do with the "Nop.Plugin.Misc.WebApi.Framework" solution (directory)?
2) Should I install the plugins using the admin "upload plugin or theme" or should I drop them into the solution in a plugin directory?


** start** "installation_instructions.txt":
Thanks a lot for purchase of the web API plugin. This archive contains two archives:
  1. The "WebApi.Backend.zip" file contains a plugin with backend methods.
  2. The "WebApi.Frontend.zip" file contains a plugin with frontend methods.
And the "Nop.Plugin.Misc.WebApi.Framework" directory with a core library. It's required and used by both Web API plugins.
Please install the first one, then install the second one:
  a) Go to admin area > configuration > local plugins.
  b) Upload the plugin archive using the "Upload plugin or theme" plugin.
  c) Scroll down through the list of plugins to find the newly installed plugin. And click on the "Install" button to install the plugin.
You can also find more information about how to install plugins at https://docs.nopcommerce.com/user-guide/configuring/system/plugins.html
Please find the web API documentation at https://docs.nopcommerce.com/developer/web-api/index.html
**end** "installation_instructions.txt"
1 year ago
HakonMM wrote:
1) I know how to install plugins, but what should I do with the "Nop.Plugin.Misc.WebApi.Framework" solution (directory)?
2) Should I install the plugins using the admin "upload plugin or theme" or should I drop them into the solution in a plugin directory?

1. Do nothing with the "Nop.Plugin.Misc.WebApi.Framework". Install two plugins - "WebApi.Backend" and  "WebApi.Frontend"
2. Instal these two plugins using the admin "upload plugin or theme"
1 year ago
a.m. wrote:
1) I know how to install plugins, but what should I do with the "Nop.Plugin.Misc.WebApi.Framework" solution (directory)?
2) Should I install the plugins using the admin "upload plugin or theme" or should I drop them into the solution in a plugin directory?
1. Do nothing with the "Nop.Plugin.Misc.WebApi.Framework". Install two plugins - "WebApi.Backend" and  "WebApi.Frontend"
2. Instal these two plugins using the admin "upload plugin or theme"


Thank you for your very quick response!
I'm running nopCommerce locally, using VS 2022.
The result:
1) "WebApi.Backend" is installed correctly.
2) "WebApi.Frontend" does not install at all. The upload succeeds, but the plugin does NOT appear in the list of plugins. What's wrong? I have tried multiple times.

I don't know if it's related to the problem, but when you look into the original nopCommerce source in nopCommerce_4.50.3_Source.zip, you can see that there is a directory here already:
\src\Plugins\Nop.Plugin.Misc.WebApi.Frontend
Can that be related to my problem?

Kind regards,
Håkon
1 year ago
HakonMM wrote:
I don't know if it's related to the problem, but when you look into the original nopCommerce source in nopCommerce_4.50.3_Source.zip, you can see that there is a directory here already:
\src\Plugins\Nop.Plugin.Misc.WebApi.Frontend
Can that be related to my problem?

Try to uninstall and delete this plugin. Then install a new one that you've purchased
1 year ago
a.m. wrote:
I don't know if it's related to the problem, but when you look into the original nopCommerce source in nopCommerce_4.50.3_Source.zip, you can see that there is a directory here already:
\src\Plugins\Nop.Plugin.Misc.WebApi.Frontend
Can that be related to my problem?
Try to uninstall and delete this plugin. Then install a new one that you've purchased


Well, it does not show up under Plugins, so I can't delete it from the admin pages.
Should I delete the folder manually, and then try to install the plugin "the normal way" using the admin pages?