1

I have created some steps between shipping and Payment form and add some field between then and applied ajax on that but i have facing an issue for not logged in user it will gave an error of 401 and redirect on login page on saving first field.

Will anyone help me how to successfully placed order without login.

i'm using Rest Api to save data in magento 2

<route url="/V1/carts/mine/set-save-data" method="PUT">
 <service class="Vendor\Module\Api\SaveNoteManagementInterface" method="saveSimpleNote"/>
 <resources>
 <resource ref="self" />
 </resources>
 <data>
 <parameter name="cartId" force="true">%cart_id%</parameter>
 </data>
</route>

This is my webapi.xml code it works properly for logged in user but for guest user it doesn't work and give 401 redirection. If you want i will share my full code for saving the data.

asked Aug 9, 2020 at 14:31
3
  • Can you share the code what you done? Commented Aug 9, 2020 at 16:32
  • I have updated my question please check @DhirenVasoya Commented Aug 9, 2020 at 17:01
  • Updated my code please check tell me anything needed. Commented Aug 11, 2020 at 16:59

1 Answer 1

0

It's been a while but it may be helpful for others coming accross this.

Your webapi.xml declares a requirement for a <resource ref="self" /> which limits access to logged in customers. If you replace that with <resource ref="anonymous" /> it will allow both customers and guest users.

As the guest cart may need slightly different backend code to handle the request, you may wish to declare a separate routewith its own url and and have that one use <resource ref="anonymous" />

answered May 16, 2023 at 19:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.