json - How to post form data for new person to Pipedrive (API) via REST -


here form not work:

<form action="https://api.pipedrive.com/v1/persons" method="post">         <!-- these hidden fields have valid values, not shown here -->     <input type="hidden" name="owner_id" id="owner_id" value="my-id" />      <input type="hidden" name="org_id" id="org_id" value="my-company-id" />      <input type="hidden" name="api_token" id="api_token" value="my-api-key" />      <input type="hidden" name="stage_id" id="stage_id" value="35" />       <b>name</b><br/>     <input type="text" name="name" id="name" id="name"/>     <br/><br/>      <b>e-mail</b><br/>     <input type="text" name="email" id="email" id="email"/>      <br/><br/>      <b>arrival</b><br/>     <input type="text" name="2fdf1284127d702e42595ce20bd8ffdf60763105" id="2fdf1284127d702e42595ce20bd8ffdf60763105"/>     <br/><br/>      <b>departure</b><br/>     <input type="text" name="2492a5afed2a9cb7948d6a22135fd4dd80de200c" id="2492a5afed2a9cb7948d6a22135fd4dd80de200c"/>     <br/><br/>      <b>message</b><br/>     <textarea style="width:300px; hight:70px;" id="7433280b87ffc7c1e3fd615eb35526273bcea6cf" name="7433280b87ffc7c1e3fd615eb35526273bcea6cf"></textarea>           <br/><br/>      <input type="submit" value="remitir"/>  </form> 

upon submission, following response returned:

{"success":false,"error":"organization not found.","data":null,"additional_data":null} 

what missing successful addition of adding new person via rest?

here api: https://developers.pipedrive.com/v1

many solution.

you can that

<script language="javascript" type="text/javascript">     function pdriveintegration()     {        var url = "https://api.pipedrive.com/v1";        var rsrc_deals = "/deals";        var api_token = "your_api_token";        var deal json = '{' + '"title":"' + name + '","org_id":"?"' +                     ',"value":"0"' + ',"currency":"gbp"' + ',"stage_id":"?"' +  ',"visible_to":"?"' + ',"status":"open"' + '"}';           var xhrdeal = new xmlhttprequest();         xhrdeal.onreadystatechange = function()         {             if (xhrdeal.readystate == 4 && xhrdeal.status == 201) {                 var obj = json.parse(xhrdeal.responsetext);                 var deal_id = obj.data.id;             }         }         xhrdeal.open("post", url + rsrc_deals + "?" + "api_token" + "=" + api_token, false);         xhrdeal.setrequestheader("content-type", "application/json");         xhrdeal.send(dealjson);  </script> </head> <body>  <form ...........>   <input type="submit" onclick="pdriveintegration();"   </form> 

therefore need ajax. if possible html form, have encode json send post. honest, tried got errors in browser.

i noticed no secure @ all, because able see source code , api_token through browser. mean info (i moved other solutions, not using html & ajax).

but anyway beginning understand need.

i'd suggest think "persons". example, before create new deal find person. if he/she exist won't create it, id , gonna put on deal.

but, in other case if person doesn't exist create person before all. after that, i'll use id on deal.

i hope useful.

byee


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -