Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while making http call: Metadata query failed for:

I have a BreezeController in a WebApi 2 project:

[BreezeController]
public class BreezeController : ApiController
{
    private readonly IBreezeRepository _repo;

    public BreezeController(IBreezeRepository repo)
    {
        _repo = repo;
    }

    [HttpGet]
    public string Metadata()
    {
        return _repo.MetaData;
    }

   [HttpGet]
   public IQueryable<Property> Properties()
   {
      return _repo.Properties;
   }
}

My client app has this code for consuming the data:

var mgr = new breeze.EntityManager({
    serviceName: "http://localhost:24830/breeze/breeze/"
});

EntityQuery
    .from('Properties')
    .select('ID')
    .using(mgr)
    .execute()
    .then(querySucceeded, _queryFailed);

function querySucceeded(data) {
    return data.results;
}

function _queryFailed(error) {
    alert("Error while making http call: " + error.message);
}

When I run my app - it's a mobile app and it opens in Ripple - I can debug into the javascript. It runs into the _queryFailed method and I get this error message:

Metadata query failed for: http://localhost:24830/breeze/breeze/Metadata; undefined

The server is also running in the debugger. It does not hit the breakpoint in the Metadata() method. But it does if I put the path into a browser, and it returns the MetaData.

What can I do now to investigate the problem?

EDIT I tried something different. I opened the individual projects in separate instances of Visual Studio (I am using VS 2015 RC). I now hit the breakpoint on the server and my client goes into the querySucceeded function. So success of a sort. So the question changes. Is there a way to set up my environment to work in just one instance of Visual Studio?

like image 278
Colin Avatar asked Nov 10 '22 13:11

Colin


1 Answers

Have you tried to manually fetch the metadata?

function fetchMetadata() {
  var manager = new breeze.EntityManager("api/breeze");
  if (manager.metadataStore.isEmpty()) {
      return manager.fetchMetadata();
  }

  return Q.resolve();
}

function start() {
  fetchMetadata().then(function () {
         // Metadata fetched.
         // Do something here.
  });
}

source: breeze fetch meta data if not present

like image 124
Jean F. Avatar answered Dec 19 '22 04:12

Jean F.