I'm using ExpressJS to code up an API that sits between my store pages and FastSpring. I'm creating a route that will get called from FastSpring when a user finishes purchasing a product. I'm using Postman to test out the API.
Everything seems to work except one aspectsetting feature values. I'm using POST, and all the values from the request are coming through to the code just fine. I'm populating a JSON object with the values from the request, and then "stringify"ing the JSON to write it to the POST body of the request. So for example, the raw post values look like:
api_key={{my_api_key}}&format=json&nojsoncallback=1&version_id={{app_version_id}}&method=limelm.pkey.generate&num_keys=1&num_acts=2&deact_limit=-1&email=fake.customer%40gmail.com&for_tfs=0&allow_vm=1&feature_name=first_name&feature_name=last_name&feature_name=organization&feature_value=Fake&feature_value=Customer&feature_value=Fake%20Organization%2C%20Inc.
The message I get back from LimeLM servers is that I need to set the feature "first_name" because it's required. And yes, I deliberately made the first_name feature a required one. Now, when I remove the last_name feature_name and last_name feature_value it works. I am thinking that stringify'ing the POST is what is causing the issue, but I'm just not sure how else to go about it since I'm using NodeJS. Coding in NodeJS requires that the request be built by using a JSON object.
Here is what the JSON object looks like before I stringify it:
{ api_key: '{{my_api_key', format: 'json', nojsoncallback: 1, version_id: {{my_app_version_id}}, method: 'limelm.pkey.generate', num_keys: '1', num_acts: '2', deact_limit: -1, email: 'fake.customer@gmail.com', for_tfs: '0', allow_vm: '1', feature_name: [ 'first_name', 'last_name', 'organization', ], feature_value: [ 'Fake', 'Customer', 'Fake Organization, Inc.'] }
Any advice on how I can prepare the POST request body in NodeJS using ExpressJS? How does the raw POST body look when building it in PHP? Unfortunately, I cannot use PHP at this point and must stick to NodeJS.
Thanks,Arie