Hi everyone, I am brand new to WeWeb and the community, this is my first post. Thanks to the WeWeb team for creating this amazing tool and thanks to the community for having me.
I do not have any coding experience. I am trying to implement the United States Postal Service (USPS) CityStateLookup API. This API takes a 5-digit Zip code as input (along with a UserID) and returns the associated city and state. I am trying to implement this dynamically on a number input field, taking the number input by the user and passing that to the API. This is my first attempt at implemting a REST API in WeWeb.
From what I understand from the documentation, you should send the Zipcode and UserID inside the request as fields in an XML format.
To do this, you should first use a POST request type, as GET doesn’t accept fields (fields are sent differently to the API than querystrings, that are sent in the URL).
As WeWeb doesn’t handle XML natively, you should use a custom binding and use JavaScript string concatenation to replace Zip5 and UserID by your variables.
Also, I’ve noticed the API accept only requests from servers, not clients (like browsers).
Thanks so much for the thorough reply @Quentin! Unfortunately it doesn’t seem to be working. Please see attached screenshot. I think I have it all setup per your screenshot, but it seems the actual variable value is not being included in the generated XML - is that right?
Is there some way for me to check the generated URL so I can see what is going wrong?
Amazing that worked to populate the variable values, thanks @Quentin! But… I’m still getting a syntax error response. Any other ideas please? Is there some way for me to see the URL generated by WeWeb so I can check what’s going wrong there?
I took a different approach and got it to work. I simply built the URL using the Concatenate formula. But I’m wondering is this acceptable? Am I breaking any best practices using this approach?
I tell people not to worry about best practices early on - especially when working with something quite complicated like XML. There is a more direct document-building approach you can apply with JS (related to my reply on a different thread) but if you can get what you need using this kind of string-building approach, I’d celebrate the win and move on to the next piece of functionality.
I’m not saying this is for the ages: you might come back to this later, but you will be smarter and more experienced by then, making a future reconsideration much sharper and cheaper than one done today.