create a product return .. not working

Leffelaer KristofLeffelaer Kristof Member Posts: 18

Hi,


I want to create a product return to : https://api.webshopapp.com/nl/returns.json

i have try with the method post and also with put (no difference)

i create this string :

{"return" : {"customerId" : 112972312 , "orderId" : 162728595 , "orderProducts": [{"quantity" : 1 , "id" : 325101505}] , "status" : "new" , "updateStock" : false , "notifyStatus" : false , "returnReason" : "kleur" , "returnAction" : "" , "staffNote" : "" , "mailMessage" : "" , "customerComment" : "" }}


but i get a error : 400 (invalid command)


I dont see wher the problem is, somebody that can help ?

Tags:

26 comments

  • gregaricangregarican Member Posts: 535 

    Looking at the API docs, you definitely should be issuing a POST request to create a new return --> https://developers.lightspeedhq.com/ecom/endpoints/return/#post-create-a-return.

    Quick couple of questions --- 1) have you verified that you have access scope permissions to access this function?, 2) have your verified that the customer ID, order ID, and item ID are correct?, 3) have you tried setting those empty string fields as null or leaving them out entirely? (e.g. - returnAction, staffNote, etc.).

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    Thanks for your comment.


    The id's are correct, I have checked several times, as you wrote, I removed all optional fields and only tried the interlaced fields by means of the POST method. but i get a 400 error. I'm going to ask lightspeed if I have permission to perform this action.


    Deze jsondata heb ik proberen door te sturen : {"Return" : {"customerId" : 123324475 , "orderId" : 163235819 , "orderProducts": [{"quantity" : 1 , "id" : 326083153}] , "status" : "new" }}

    naar het adres : https://api.webshopapp.com/nl/returns.json


    If you have any tips, please let me know

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Hi @Leffelaer Kristof,

    Thank you for reaching out to us.

    Can you provide me your shop number, so I can check for you?

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18
    edited October 9

    Thank you ! @LucienVersendaal


    the shop id : 292169

    Post edited by Leffelaer Kristof on
  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Hi @Leffelaer Kristof,

    What I see is that this item doesn't exist anymore, and the Return is manually created.

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    hi @LucienVersendaal

    that may be correct, because I created the return via the manual way (dashboard ecom) because I can't wait until I have the api ready! but I did try before doing this.


    The fact that the product no longer exists does not play a role, you can also create it via ecom dashboard .... something is wrong but I cannot find it I have checked the manual again .... unless I have no rights did this run because he? the ecom is linked to lightspeed retail?

    but this should make no difference, would it?

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    No that doesn't matter you can create a return with eCom API if you have also a Retail account that is linked to it.

    Can you share me your KEY that you are using, so I can check the rights?

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    @LucienVersendaal

    I thought so too .. wouldn't make sense,


    hereby the key ...: 6fcc8095a093f4d517a4b3eb1a79f7e9


    Is it an option that I send the date and time so that you can see a little more in the logs?

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Can you check again now, there was something with the rights.

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    @LucienVersendaal

    Ik heb vandaag geprobeerd maar zonder succes.

    deze string heb in een POST gegeven :

    {"Return" : {"customerId" : 123616357 , "orderId" : 163656327 , "orderProducts": [{"quantity" : 1 , "id" : 326876497}] , "status" : "new" , "updateStock" : "false" , "notifyStatus" : "false" , "returnReason" : "te groot" , "returnAction" : "" , "staffNote" : "" , "mailMessage" : "" , "customerComment" : "" }}


    naar : https://api.webshopapp.com/nl/returns.json


    tussen 15u en 16u een paar keer uitgevoerd ... error 400 methode niet toegestaan.


    Ik snap er niks van !

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator
    edited October 14

    I'm trying to create a return with your payload and was getting an error message, "This feature has been disabled". I guess you got the same. The merchant needs to enable this setting in the back office. As you can see it is disabled.


  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    @LucienVersendaal

    Great job !!!!


    That was the problem now, i enabled it and try again and it works....


    Thank you verry much


    Have a nice evening

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Perfect!

    Good to hear that.

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    Hi @LucienVersendaal , after create a return, i have to make a credit invoice ... but i get a error 401 not autohrised .. can you check again for the rights ? or is here also a setting in lightspeed ?

    without credit invoice my retail not update the stock.....


    thanx

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    @Lightspeed Team @LucienVersendaal

    Could jullu check if I have rights to create a credit invoice with this api key?

    We get the error : error 401 not autohrised


    key : 6fcc8095a093f4d517a4b3eb1a79f7e9


    Thanx

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Hi @Leffelaer Kristof,

    You've full permission. What is the request you're making? Please provide me the payload and request.

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    hi, @LucienVersendaal

    https://api.webshopapp.com/nl/orders/164149210/credit.json

    (164149210 = the order id)

    with POST

    {"credit" : { "creditPayment": true , "creditShipment": true , "notifyNew": false , "updateStock": true , "orderProducts" : [{"quantity" : 1 , "id" : 327828389}] }}


    (327828389 = the product id)


    this i try to post at 28/10 on +/- 16u50


    Thanx in advance

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Hi @Leffelaer Kristof,

    I see this order has already a credit invoice manually created, so I can test it on this order. Everything is looking good about your code, all IDs are correct.

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    @LucienVersendaal

    Thanx, but its not working !

    I created it manualy, when i have a new retour i let you know ! maybe this evening.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Yes please let me know.

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18
    edited October 30

    Hi @LucienVersendaal

    I have a new order that you can est to make a credit invoice true the api

    Ordernr :

    ord03596


    id order :

    164708945


    request string tha i use :

    https://api.webshopapp.com/nl/orders/164708945/credit.json


    payload that i have created :

    {"credit" : { "creditPayment": true , "creditShipment": true , "notifyNew": false , "updateStock": true , "orderProducts" : [{"quantity" : 1 , "id" : 328893845}] }}


    Thanx

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Hi @Leffelaer Kristof,

    Thanks. As you can see I used your payload and was getting a 200 status.

    Also in the UI it is correct:


  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Are you using an Authorization : Basic key:secret token in the header?

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    @LucienVersendaal

    Yes , the same that i use for make a return (that works fine)

    This is the code :

     httpWebRequest.ContentType = "application/json"

    httpWebRequest.Method = "POST"

    httpWebRequest.Headers.Add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes(Home.apikey & ": " & Home.apisecret)))

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

  • Leffelaer KristofLeffelaer Kristof Member Posts: 18

    @LucienVersendaal

    I found the probleme... a stuppit space after the : between api key and secret !

    Just one more question about to create a return.

    every time i post a return it gets the status "New" i have try to give the payload status : "authorized" but in lightspeed it comes as "New"


    Is it not possible to to this at once or have or must i make a sepperate request to change it ?


    Thanx

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 499 moderator

    Hi @Leffelaer Kristof,

    Okay good to hear that you've found the issue.

    The first creating of a return is always a status "new". So you'll have to update the status in a separate call.

Sign In or Register to comment.