Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Complemento de Office: obtenga 404 al acceder a un ApiController

Estoy aprendiendo a crear un complemento ppt de acuerdo con el tutorial oficial . Seguí los pasos de la sección Insertar una imagen , pero descubrí que el complemento no funcionaba correctamente. Cuando hice clic en el botón "Insertar imagen", el complemento visitó /api/Photo/ a través de ajax, pero el código de estado siempre fue 404.

Esta es la función llamada cuando hice clic en el botón:

 function insertImage() { // Get image from from web service (as a Base64 encoded string). $.ajax({ url: "/api/Photo/", success: function (result) { insertImageFromBase64String(result); }, error: function (xhr, status, error) { // always 404 showNotification("Error", "Oops, something went wrong."); } }); }

Y este es el ApiController:

 namespace HelloWorldWeb.Controllers { public class PhotoController : ApiController { public string Get() { string url = "http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1"; // Create the request. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); WebResponse response = request.GetResponse(); using (Stream responseStream = response.GetResponseStream()) { // Process the result. StreamReader reader = new StreamReader(responseStream, Encoding.UTF8); string result = reader.ReadToEnd(); // Parse the xml response and to get the URL. XmlDocument doc = new XmlDocument(); doc.LoadXml(result); string photoURL = "http://bing.com" + doc.SelectSingleNode("/images/image/url").InnerText; // Fetch the photo and return it as a Base64 encoded string. return getPhotoFromURL(photoURL); } } private string getPhotoFromURL(string imageURL) { var webClient = new WebClient(); byte[] imageBytes = webClient.DownloadData(imageURL); return Convert.ToBase64String(imageBytes); } } }

Me pregunto cómo puedo configurar los enrutadores. No se ha discutido en el tutorial y estoy confundido si se configura automáticamente.

¡Gracias!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!