I had a working client side API call to return some data - worked perfectly, but I want to conceal the source so implemented the same call on the server side, it’s an exact replica (and I’ve also tried all kinds of variations) but I keep getting the following error:
stack: "TypeError: data should be a string, Buffer or Uint8Array↵
Noting I can define the schema fine on the server side when using the URL and the query parameter that would be passed via the form - but when I try to use dynamic parameter value e.g. {{$_POST.profile}} then it fails.
Not sure if it’s a bug or if I’m just doing something wrong - has anyone experienced the above, and was able to solve it?
@Teodor - tagging this as I need your expertise to define if this is a bug or user error here. There are lots of strange things going on here.
It seems to store the previous input data or queries even when there are none and then apends them to the URL - if I use the exact URL path i’m trying to generate in the client side - it works fine, if I ‘define api schema’ on the server side it works fine - the moment I try to use the input data / query inputs it fails. Running the API call in a browser also works perfectly fine. Can you provide some support here?
If I turn this server connect form into a API form with exactly the same call information - it works perfectly.
message: “data should be a string, Buffer or Uint8Array”
Again, this setup works perfectly when just applying the correct query in browser, or as a form API or as a client side API action - it just doesn’t work via server connect to the workflow.
When I try the same call via API Form but use more than one input parameter - it also fails in the same way.
Where does it generate this URL? The url looks from the server connect action, not from the api endpoint. In the server connect action you use {{$_POST.profile}} while seeing the url you seem to pass the parameter in the query instead of a post.
Where exactly do you get this error, was it returned from the server connect call?
What you see in the network tab is not the api call made by the server action, it is the call to the server action. How do you call the server action, probably not using a post?
appreciate your help here Patrick. I did notice online that this error: [quote=“mgaussie, post:4, topic:23795”]
message: “data should be a string, Buffer or Uint8Array”
[/quote] is actually a common one for NodeJS and there are various solutions on stack overflow.
However, this is what I’m doing - so I hope it’s just user error you can help me navigate.
We have an external API - which we use a GET call to match our input against their database and this returns information matching our GET Call input.
I’ve tried to do this via API Form, and SC. Ideally I build the API in SC so we are hiding the URL and we call our own Rest API that then calls their API to return the data.
This is the SC info:
(api key not shown for security reasons)
If i enter a profile in this post - it returns the correct info
If I then try to SC to this API Action - it fails, and as you can see from the above paths - it is apending the profile twice, when I am inputting only once.
When I try API Form instead I get the same issue or even just a ‘invalid api key’ even when I’m using the same one on the SC that works fine!
In addition, you can see in the UI here, I only have entries in ‘query’ yet input data is highlighted as if it’s stored previous data that was deleted - and seems it might be adding that to any query path:
Are you using a server connect form to post the profile variable to the server action? It looks like you are doing a get instead of a post, the profile should not be visible in the querystring.
I have just tried another call (there are 3 different ways to enrich data via this API we are using).
SC form (POST) two inputs.
SC Action - call the API URL with a GET
in Query - using both fields as POST from the form (that have been correctly mapped by importing the fields from the form itself).
I get this error still and again in network tab:
message: “data should be a string, Buffer or Uint8Array”
NEW:
I have now also tried removing ‘query’ and instead using input data
Again you can see the blue query remains as if it’s storing it, and not recognizing it’s been deleted.
And with this call - I simply get the same error:
message: “data should be a string, Buffer or Uint8Array”
Please help @patrick - this is such a basic API call.
Do you run the NodeJS server on localhost? If it is running the server directly on port 3000 then you should see errors in the console within Wappler, if you are running it in Docker then you have to check the log.
I want to know which file/line throws the error that you are getting.
Did you also test with a static value instead of the {{$_POST.profile}} expression?
Thank you - I assume this would be fairly high priority - as it seems no api’s are working (certainly in my case) and is grinding this project to a hault at the moment.