cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I'm getting a 301 error whenever I try to purchase a number through a REST Client

joeytextline
Occasional Contributor

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?

12 REPLIES 12

joeytextline
Occasional Contributor

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

Roland_Ian
Employee
Employee

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. 

 

Roland-Ian Clothier, Developer Support Engineer

Glad to see you solved it!  JSON can be fiddly for sure, so ensure its valid is always a good approach. 

Roland-Ian Clothier, Developer Support Engineer