title: Error 403 AJAX request JavaScript (instagram direct message)
body: <p>I used a script to send direct message automatically in browser console</p>
  <p>I login instagram with browser and go to inspect element and tab console copy this code</p>
  <pre><code>function getCookie(cname) {
      let name = cname + &quot;=&quot;;
      let decodedCookie = decodeURIComponent(document.cookie);
      let ca = decodedCookie.split(';');
      for(let i = 0; i &lt;ca.length; i++) {
          let c = ca[i];
          while (c.charAt(0) == ' ') {
              c = c.substring(1);
          }
          if (c.indexOf(name) == 0) {
              return c.substring(name.length, c.length);
          }
      }
      return &quot;&quot;;
  }
  var deviceID = '89765456789032222';
  
  var user = 192417402;
  var formData = new FormData();
  
  formData.append(&quot;csrftoken&quot;, getCookie('csrftoken'));
  formData.append(&quot;device_id&quot;, &quot;android-&quot;+deviceID); 
  formData.append(&quot;_uuid&quot;, Date.now()); 
  formData.append(&quot;recipient_users&quot;, '[[&quot;' + user + '&quot;]]'); // user id can be found on https://www.instagram.com/username/?__a=1
  formData.append(&quot;client_context&quot;,  Date.now()); 
  formData.append(&quot;text&quot;, 'aaaaaaaa'); 
  
  var xhr = new XMLHttpRequest();
  xhr.open(&quot;POST&quot;, &quot;https://i.instagram.com/api/v1/direct_v2/threads/broadcast/text/&quot;);
  xhr.withCredentials = true;
  xhr.send(formData);
  </code></pre>
  <p>It return 403 error to me how to fix it</p>