Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team

I have been trying to fix this error and cant seem to be able to fix it since yesterday. I need some help, basically i want to send message back to my things network using Post method.


jquery.js:9664 POST https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0 404 (Not Found)

Access to XMLHttpRequest at 'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0' from origin 'https://thingspeak.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


What I have tried:

HTML
<pre> // button for switch functionality on/off.
  $(document).ready(function() {
    $('#toggle_event_editing ').click(function(){
      if($(this).hasClass('locked_active')) {
      $('#switch_status').html('Switched off');
        $.ajax({
          url:'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0',
          type:'POST',
          data:{
            payload_raw: 'AAA',
            dev_id:'mkr1300'
          },
         success:function(response){
         alert(response);
          },
         error:function() {
           $('#error').text("There was an error while processing your request. Please try again");
          }
        }); 

    }else{
    $('#switch_status').html('Switched on.');
    $.ajax({
      url:'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0',
      type:'POST',
      data:{
        payload_raw:'AAE',
        dev_id:'mkr1300'
      },
      success:function(response) {
      alert(response);
      },
      error:function() {
      $('#error').text("There was an error while processing your request.Please try again");
      }
    });
    }
    });
  });
Posted
Updated 16-Dec-19 22:14pm

1 solution

thethingsnetwork doesn't support browser-based ajax so there is no way to access its API from a browser. You'll need to supply an API on your own website that connects to thethingsnetwork and call that API from your ajax code.
 
Share this answer
 
Comments
gcogco10 17-Dec-19 4:21am    
Hi Mate, unfortunate part im using thingspeak and its uses Rest API, but to this issue i am restricted to communicate to my things network gateway as a result of the CORS security authentication. I am trying to follow currently this link, https://putsreq.com/agT2991XWmifYEvy20Uy/inspect

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900