Forum Discussion

CodeMaker's avatar
CodeMaker
Contributing User
6 years ago

Is MVC in Text Mode?

I've taken the following piece of code from the MYOBApiCSharp CompanyFilesForm.cs sample and tried to apply it to my MVC C# code.

 

_configurationLocal = new ApiConfiguration(LocalApiUrl);
var cfsLocal = new CompanyFileService(_configurationLocal);
cfsLocal.GetRange(OnComplete, OnError);

 

Fortunately I'm able to send my key and secret to myob and get the required token, send them again so that I retrieve the authoriation code.

 

I no longer get the 'Bad Request' message, so I feel I'm on the right track, but now, when I get to the GetRange() function, I get the following error:

 

'Unexpected character encountered while parsing value: <. Path '', line 0, position 0.'

Because the first charater read is a < (less than) it's as if the CompanyFileService class is returning in "application/text" format, with XML, and GetRange is expecting "application/json".

I've tried converting to a WebApi application however I still have the same result.  also uder result

Is there a way to make MVC C# tell CompanyFileService() to stick to Json?   Or am I way off track?

A working MVC C# sample would be appreciated.

Thank you in advance

  • Ok, I fixed it.   I rebuilt my application using WebApi.

  • CodeMaker's avatar
    CodeMaker
    Contributing User

    Ok, I fixed it.   I rebuilt my application using WebApi.