09-05-2023 06:51 AM - edited 09-06-2023 09:15 PM
For some reason, the exact same credentials, data and endpoint work fine when I do a CURL request:
curl -i -X POST -u apikey:secret 'https://numbers.api.sinch.com/v1/projects/{project_id}/availableNumbers:rentAny' \ -H 'Content-Type: application/json' \ -d '{ "regionCode": "US", "type": "LOCAL", "numberPattern": { "pattern": "206", "searchPattern": "START" }, "smsConfiguration": { "servicePlanId": "service_plan_id" } }'
But when I use my Ruby console, and try to do this through a REST Client, I get the following error:
RestClient::MovedPermanently (301 Moved Permanently)
What's a common reason for the 301 error?
Solved! Go to Solution.
09-07-2023 07:06 PM
For those who need help with the 301 error:
I had an extra / in the URL. Make sure that the URL is 100% matching.
For those who are getting a similar "invalid character" 400 error with a rest client:
Try converting your payload into a JSON string. All that I had to do here, was make payload = payload.to_json
09-07-2023 11:47 PM
Hi
Yes sorry, I never meant to doubt your ability. 😅
I do it as this might be helpful to others who find this post, they might be just beginning with the concepts.
09-07-2023 11:48 PM
Glad to see you solved it! JSON can be fiddly for sure, so ensure its valid is always a good approach.