Actually, what I'm trying to do:
- Login using
contributor-accounts.shutterstock.com(done!) - make a post request to send a picture there (problem!)
The wrapper code itself around RestSharp:
public class Requester { public RestClient Client = new RestClient(); public Requester() { Client.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"; } private IRestResponse GetSingle(string url, int timeOutMs) { Client.BaseUrl = new Uri(url); var request = new RestRequest(); request.Timeout = timeOutMs; return Client.Execute(request); } public IRestResponse Post(string url, string filePath) { Client.BaseUrl = new Uri(url); var request = new RestRequest(url, Method.POST); request.AddFile("someFileName", filePath); return Client.Execute(request); } public IRestResponse CorpsPost(string baseUrl, string remoteDomainUrl, string filePath) { Client.BaseUrl = new Uri(baseUrl); var basePage = GetSingle(baseUrl, 6000); var optionsRequest = new RestRequest(baseUrl, Method.OPTIONS); Client.Execute(optionsRequest); //some addtitional code here? var request = new RestRequest(remoteDomainUrl, Method.POST); request.AddFile("someFileName", filePath); return Client.Execute(request); } } The problem is that sending a file (post) goes to another domain:
https://media-upload.shutterstock.com
and, as a result, the browser automatically uses CORS . Additional information can be read here: tyts
So, question 2:
Is it possible to simulate a CORS request without a browser?
If possible, how to do it with RestShapp? That is, how to fix the CorpsPost () method so that it works in principle?