Question:
My function on httpsFunctions.js are trying to create a coupon, but I’m receiving a BAD REQUEST.
Product:
I’m using httpfunction.js on WIX BackEnd to create a coupon based on the request.path. I’m creating exatcly how it’s on the docs, but I’m receiving a bad request. i already printed the request, the specification and it’s all good
What are you trying to achieve:
[Explain the details of what you are trying to achieve. The more details you provide, the easier it is to understand what you need.]
What have you already tried:
THIS IS MY FUNCTION RUNING ON HTTPSFUNCTIONS.JS ON WIX BACKEND :
export async function post_createcupom(request){
let specification = {
"percentOffRate":request.path[0],
"name":request.path[1],
"code":request.path[2],
"usageLimit":request.path[3],
"startTime": new Date().toISOString(),
"scope": {
"namespace": "stores"
},
}
const options = {
headers: {
'Content-Type': 'application/json'
}
};
const elevatedCupom = wixAuth.elevate(coupons.createCoupon);
try {
const result = await elevatedCupom(specification);
options.body ={
status: true,
message: "cupom criado",
result: result
};
return ok(options);
} catch (error) {
options.body = JSON.stringify({
message: "cupom nao criado",
status: false,
erro: error,
request01: request,
specification: specification
});
return notFound(options);