How to fix the ‘Missing required request header. Must specify one of: origin,x-requested-with’ Ajax Error

I did a bit more digging into the Postman code that was able to run successfully and got the correct answer from that. Here’s the code I used to correctly run the API and pass the information cross-domain.

        // Set URL to the Create patient endpoint        
        const Url = "https://cors-anywhere.herokuapp.com/https://staging.micromerchantsystems.com/mmsgatewayapistaging/api/patient/create";

        // On button ajax call to create a new user with the above data

        $('.btn').click(function () {
            // The input value variables NEED to be defined and set after the click function
            // so that the value can be received and passed into the userData variable.

            // Define User data here ** Currently static information **
            // Need to set variables based on input value to the correct identifier
            // EX: "FirstName": $('#first_name').val();
            var user_firstName = $("#first_name").val();

            const userData = {
                "RequestingClient": {
                    "ClientId": "XXXXXX",
                    "MemberId": "XXXXXXX"
                },
                "Pharmacy": {
                    "IdentifierType": 2,
                    "Identifier": "XXXXXXX"
                },
                "LastName": "Test",
                "MiddleInitials": "X",
                "FirstName": user_firstName,
                "Gender": "M",
                "DOB": "01/01/1990",
                "Email": "[email protected]",
                "PhoneNumber": "1234567890",
                "MobileNumber": "1234567890",
                "BusinessNumber": "1234567890",
                "PatientIdentifiers": [
                    { "IdentifierType": 1, "IdentifierType": "12345" }

Leave a Comment

tech