0

I am new to using CURL. I am trying to connect to a SharePoint URL and pull the data in the form of json. My URL looks like this:

.../_api/web/lists/GetByTitle('titles list')/items

If I give the URL as it is without any encoding, it fails with a HTTP/1.1 400 Bad Request error.

I tried using -G and --data-urlencode like below:

curl -v -G -L --ntlm --user user:password -H 'Accept: application/json;odata=verbose' ".../_api/web/lists/GetByTitle" --data-urlencode "('titles list')" -d "/items"

doing this will convert my URL to .../_api/web/lists/GetByTitle?%28%27titles%20list%27%29&/items

But it fails with HTTP/1.1 404 Not Found since using -G will append to the URL with a ? and & . Putting ? and & to append to the URL will give me a different URL and hence the 404 not found error.

I have no issues accessing other end points like ../_api/web/lists since there is no need to encode it I guess.

How do I properly encode my URL and get the data without any errors?

Any help would be appreciated. Thank you.

1
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. Commented Feb 13, 2018 at 16:31

1 Answer 1

-1

I was able to solve the issue by directly giving URL with the encoded characters to cURL command. Like this:

curl -v -L --ntlm --user user:password -H 'Accept: application/json;odata=verbose' ".../_api/web/lists/GetByTitle%28%27titles%20List%27%29/items"

I hope this helps someone. I know I am no expert with linux or cURL and any better answers to this are welcome.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.