I have figured out what my issue is. I was creating the html file on my local PC and testing it there, but to upload the file using the ticket API I was getting a CORs policy error. The fix was to place the file directly on the server and access the html file from the Server's URL path.
I am inexperienced when it comes to APIs as well as coding in general. I did not fully understand how to send the information and decided to build the function in Javascript. For any that may be in the same boat as me, here is the function snippet I used to create a ticket using the API.
async function submitData() {
//placed this alert to confirm the function is firing off
alert("Ticket Submitted");
//using a html form to get the information from the user and on submit this function places the data into these variables
var Subject = document.getElementsByName("FormSubject")[0].value;
var Description = document.getElementsByName("FormDescription")[0].value;
var Email = documnet.getElementsByName("FormEmail")[0].value;
//placed the server API string into a variable to easily send data later. also added the variables that were created earlier to the string
const api_url = "serverapi.aspx?Action=AddTicket&Key=keystring&Subject=" + Subject + "&Description=" + Description + "&Email=" + Email
//store the XMLHttpRequest into a variable
var xhttp = new XMLHttpRequest();
//Store an attached file from a form if needed
var objFile = document.getElementById("IDfile").files[0];
//creating a form data to submit the file to the API
var Data = new FormData();
Data.append("Files", objFile);
//calling the XMLHttpRequest to send the data to API also added some progress statements which ultimately made me realize my console was not keeping data logged when the page refreshed. This then lead to me realizing I was getting the CORS Policy error
xhttp.open("POST", api_url);
console.log('OPENED: ', xhttp.status);
xhttp.onprogress = () => {
console.log('LOADING: ', xhttp.status);
};
xhttp.onload = () => {
console.log('DONE: ', xhttp.status);
};
xhttp.send(Data);
}
As I stated before I don't know much about coding, so If anyone has advice on how this could be done I am open to suggestions. Thank you.