We have a customer in which there is an API that needs to be posted on https. We have a node.js application and Using Fellix's node-form-data package () to create presentations, while call client testing works fine against HTTP-API, when we try to call production API that uses https Reactions with API 400 Confirms that the client is telling us, is due to calls to HTTP
In our submission we can specify how https?
Our code looks like this:
var freddata = requires (form-information '); Var CouponForm = New FormData (); CouponForm.Append ('data', '{coupon}: "" code ":"' + couponCode + '"," discount ":"' + + discount credit + '"," type ":" percent "," Product ":" '+ Product ID +' "," Time ":" 1 "," Finished ":" '+ couponExpiresDt +' "}} '); CouponForm.submit ({hostname: config.client_api_host, path: '/ api / coupon / add', auth: auth}, function (err, res) {res.resume (); if (err) {logger.log (' 'Error', 'client api discount post error:'); logger.log ('error', {err: err}); callback (mistake);} and if (res.statusCode! = 200) {logger.log ( Logger.log ('error', 'client error', 'error', 'customer API discount post response error:'); console.log ('error', res); logger.log ('error', {statusCode : Reserver.code}; logger.log ('error' (body: res.body}); Callback (new error ('Create Client API Postcode Error:', res.statusCode));} and {logger.log ('Info', "Customer coupon code" + couponCode + "is apparently created"); Callback (empty, {coupon_code: couponcode, expiry: couponExpiresDt}}}}};
According to you, you must pass in the protocol: 'https:'
in your options.
couponForm.submit ({hostname: config.client_api_host, path: '/ api / coupon / add', auth: auth, protocol: 'https:'}, function (mistake, ridge) {[...] });
No comments:
Post a Comment