Jesse
July 18, 2019, 4:41am
1
Do we have anything similar to the HTTP Put request? For what I am doing web.PostJson doesnt seem to work. Here is my script.
function updatepunch(punchid,punchtype,time) {
var update = web.PostJson('https://api.7shifts.com/v1/'+method2+'/'+punchid+'','{ "time_punch": { "clocked_in": "'+time+'" }}',''+apikey+'','');
return update;
}
But the api specifically says it needs PUT for updating vs creating. Below is a script for creating and it works.
This script works just fine:
function punch(userpin,timein,timeout) {
var userid = getuser(userpin);
var execpunch = web.PostJson('https://api.7shifts.com/v1/'+method2+'/','{ "time_punch": { "user_id": '+userid+', "location_id": 25721, "clocked_in": "'+timein+'", "clocked_out": "'+timeout+'" }}',''+apikey+'','');
var punchid = JSON.parse(execpunch);
var punchidresult = punchid.data.time_punch.id;
return punchidresult;
}
Jesse
July 18, 2019, 4:43am
2
Sigh this is where I miss Emre so much.
4 Likes
Smifis
July 18, 2019, 5:50pm
3
I think the best workaround to get things moving again is to build a quick littler wrapper.
Probably easily done in reactJS or the likes. I’m more verse in PHP so would throw a script onto one of my locally hosted web servers and go from there.
As an example you can use CURL in a php script to forward the script and return the result. something like this. this isn’t texted but will probably work.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.MyApiEndpoint.com/somewhere/add");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
$data = curl_exec($ch);
echo $data;
curl_close($ch);
?>
Jesse
July 18, 2019, 6:29pm
4
Yes I know how to do all of that but I am specifically asking about helpers available to Sambapos.
I think I know the answer already but I wanted to make sure I didnt miss an updated feature somewhere.
1 Like
Smifis
July 18, 2019, 6:54pm
5
Gotcha!
Maybe a bit of digging outside of the box will show up something special
javascript
1 Like
Jesse
July 18, 2019, 7:24pm
6
I can use the webclient .net resources but I was hoping for a premade helper.
1 Like
Smifis
July 18, 2019, 7:25pm
7
Forgot we can use .net
Whoever came up with that idea needs a parade
2 Likes