I'm trying to use MATLAB compiler to make a program a standalone application. The program runs fine in MATLAB, but gives an error as a standalone application. I don't think the problem is with missing files or mismatched versions of the compiler and runtime.
The compiled program runs at first, the gives an error and tells me on what line it occurred. The problem is with the webwrite command. I'm using it to send an email through the Gmail API. This requires me to change the MediaType in weboptions from the default of 'application/x-www-form-urlencoded' to 'application/json'. When I include the email message in the webwrite command in a structure, it is converted to a JSON object and posted to the specified URL. This works in MATLAB, but the compiled program gives an error that says 'The input cannot be converted to JSON'. The lines of code pertaining to this are:
options = weboptions('MediaType','application/json','RequestMethod','post');
I'm guessing the input mentioned in the error is the structure, but there is no problem encoding it as JSON in MATLAB, so I don't know what the problem is.
EDIT: I have looked at the FAQ sites and tried some of their suggestions. I confirmed that my versions of MATLAB and runtime match. I have also confirmed that the functions I created are all there. I have successfully compiled other programs; it really seems to be an issue with the webwrite command.
In response to Dasharath's questions:
1. I don't want to post the full code. There are 6 functions it depends on, which would be a pain to post. More importantly, because I am working with the gmail api, providing my full code would allow anybody to send email from my account. I'm using a test email, but I still don't want to do this. I know this makes it way harder for people to help, and I appreciate your efforts. I can post segments of the code if needed. I might write a version that will allow people to use their own emails. Let me know if that would be helpful.
2. I am doing all the coding and testing on the same machine. I just got back to college, so I might test it out on the school computers.
3. Access token is part of the URL the webwrite command posts to. It is a code that the Gmail API uses for authentication, and is only valid for an hour before needing to be refreshed, so that is why it is a variable and not just typed in like the rest of the URL. The message is passed in the structure named "data". I'm not entirely sure how it works, as I relied largely on trial and error, but the MATLAB documentation says it is converted to a JSON object.
4. The exact text of the error is "The input cannot be converted to JSON. Error in => prettyaurora.m at line 27."
Thanks for your help.