upload new media via rest api not work on wordpress.com blog
-
Hi,
i use https://public-api.wordpress.com/rest/v1.1/sites/$siteid/media/new for upload new image, the same code works for blogs not hosted on wordpress.com, if i try on a blog hosted on wordpress.com i obtain
{“error”:”invalid_input”,”message”:”No media provided in input.”}
i have try the same code and the same image on different blog and for me all blog hosted on wordpress.com have the same problem.
this is the code i use in c#
HttpClient client = new HttpClient(); HttpResponseMessage response = null; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BEARER", Const.getCurrenLogin().token); var content = new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)); var randomAccessStream = await file.OpenReadAsync(); Stream stream = randomAccessStream.AsStreamForRead(); content.Add(new StreamContent(stream), "media", file.Name); response = await client.PostAsync(new Uri("https://public-api.wordpress.com/rest/v1.1/sites/" + id + "/media/new"), content); var result = await response.Content.ReadAsStringAsync();
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘upload new media via rest api not work on wordpress.com blog’ is closed to new replies.