Actualizar Stock

Actualizar stock de un artículo y almacén especifico.

PUT https://api.appsat.net/v1/ArticulosStock/articulo_id/

curl "https://api.appsat.net/v1/ArticulosStock/articulo_id/" \
  -X PUT \
  -d "[\n  {\n    \"empresa_id\": 1,\n    \"sucursal_id\": 1,\n    \"almacen_id\": 7,\n    \"articulo_stock_cantidad\": 150,\n    \"articulo_stock_cantidad_minima\": 5,\n    \"articulo_stock_planta\": \"\",\n    \"articulo_stock_zona\": \"\",\n    \"articulo_stock_columna\": \"\",\n    \"articulo_stock_fila\": \"\",\n    \"articulo_stock_posicion\": \"\",\n    \"articulo_stock_fecha_add\": \"2020-09-23 22:43:01\",\n    \"articulo_stock_fecha_upd\": \"2020-10-08 13:42:02\",\n    \"articulo_stock_delete\": 0,\n    \"articulo_stock_custom_id\": \"\"\n  }\n]" \
  -H "accept: */*" \
  -H "key: " \
  -H "Content-Type: application/json"
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function(e) {
  var response = e.target.responseText;
  console.log(response);
});
xhr.addEventListener('error', function(e) {
  console.error('Request errored with status', e.target.status);
});
xhr.open('PUT', 'https://api.appsat.net/v1/ArticulosStock/articulo_id/');
xhr.setRequestHeader('accept','*/*');
xhr.setRequestHeader('key','');
xhr.setRequestHeader('Content-Type','application/json');
var body = '';
body += '[\n';
body += '  {\n';
body += '    "empresa_id": 1,\n';
body += '    "sucursal_id": 1,\n';
body += '    "almacen_id": 7,\n';
body += '    "articulo_stock_cantidad": 150,\n';
body += '    "articulo_stock_cantidad_minima": 5,\n';
body += '    "articulo_stock_planta": "",\n';
body += '    "articulo_stock_zona": "",\n';
body += '    "articulo_stock_columna": "",\n';
body += '    "articulo_stock_fila": "",\n';
body += '    "articulo_stock_posicion": "",\n';
body += '    "articulo_stock_fecha_add": "2020-09-23 22:43:01",\n';
body += '    "articulo_stock_fecha_upd": "2020-10-08 13:42:02",\n';
body += '    "articulo_stock_delete": 0,\n';
body += '    "articulo_stock_custom_id": ""\n';
body += '  }\n';
body += ']';
xhr.send(body);
import requests

url = 'https://api.appsat.net/v1/ArticulosStock/articulo_id/'
headers = {'accept': '*/*','key': '','Content-Type': 'application/json'}
body = """[
  {
    "empresa_id": 1,
    "sucursal_id": 1,
    "almacen_id": 7,
    "articulo_stock_cantidad": 150,
    "articulo_stock_cantidad_minima": 5,
    "articulo_stock_planta": "",
    "articulo_stock_zona": "",
    "articulo_stock_columna": "",
    "articulo_stock_fila": "",
    "articulo_stock_posicion": "",
    "articulo_stock_fecha_add": "2020-09-23 22:43:01",
    "articulo_stock_fecha_upd": "2020-10-08 13:42:02",
    "articulo_stock_delete": 0,
    "articulo_stock_custom_id": ""
  }
]"""

req = requests.put(url, headers=headers, data=body)

print(req.status_code)
print(req.headers)
print(req.text)
#include <stdio.h>
#include <curl/curl.h>

int main(void)
{
	CURL *curl;
	CURLcode res;

	curl = curl_easy_init();
	curl_easy_setopt(curl, CURLOPT_URL, "https://api.appsat.net/v1/ArticulosStock/articulo_id/");
	curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
	/* if redirected, tell libcurl to follow redirection */
	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

	struct curl_slist *headers = NULL;
	headers = curl_slist_append(headers, "accept: */*");
	headers = curl_slist_append(headers, "key: ");
	headers = curl_slist_append(headers, "Content-Type: application/json");
	curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

	char *body ="[  {    \"empresa_id\": 1,    \"sucursal_id\": 1,    \"almacen_id\": 7,    \"articulo_stock_cantidad\": 150,    \"articulo_stock_cantidad_minima\": 5,    \"articulo_stock_planta\": \"\",    \"articulo_stock_zona\": \"\",    \"articulo_stock_columna\": \"\",    \"articulo_stock_fila\": \"\",    \"articulo_stock_posicion\": \"\",    \"articulo_stock_fecha_add\": \"2020-09-23 22:43:01\",    \"articulo_stock_fecha_upd\": \"2020-10-08 13:42:02\",    \"articulo_stock_delete\": 0,    \"articulo_stock_custom_id\": \"\"  }]";
	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);

	/* Perform the request, res will get the return code */
	res = curl_easy_perform(curl);
	if (res != CURLE_OK) {
		fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
	}
	/* Clean up after yourself */
	curl_easy_cleanup(curl);
	return 0;
}
/* See: http://stackoverflow.com/a/2329792/1127848 of how to read data from the response. */
URL url = new URL("https://api.appsat.net/v1/ArticulosStock/articulo_id/");
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("PUT");
con.setRequestProperty("accept", "*/*");
con.setRequestProperty("key", "");
con.setRequestProperty("Content-Type", "application/json");

/* Payload support */
con.setDoOutput(true);
DataOutputStream out = new DataOutputStream(con.getOutputStream());
out.writeBytes("[\n");
out.writeBytes("  {\n");
out.writeBytes("    \"empresa_id\": 1,\n");
out.writeBytes("    \"sucursal_id\": 1,\n");
out.writeBytes("    \"almacen_id\": 7,\n");
out.writeBytes("    \"articulo_stock_cantidad\": 150,\n");
out.writeBytes("    \"articulo_stock_cantidad_minima\": 5,\n");
out.writeBytes("    \"articulo_stock_planta\": \"\",\n");
out.writeBytes("    \"articulo_stock_zona\": \"\",\n");
out.writeBytes("    \"articulo_stock_columna\": \"\",\n");
out.writeBytes("    \"articulo_stock_fila\": \"\",\n");
out.writeBytes("    \"articulo_stock_posicion\": \"\",\n");
out.writeBytes("    \"articulo_stock_fecha_add\": \"2020-09-23 22:43:01\",\n");
out.writeBytes("    \"articulo_stock_fecha_upd\": \"2020-10-08 13:42:02\",\n");
out.writeBytes("    \"articulo_stock_delete\": 0,\n");
out.writeBytes("    \"articulo_stock_custom_id\": \"\"\n");
out.writeBytes("  }\n");
out.writeBytes("]");
out.flush();
out.close();

int status = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while((inputLine = in.readLine()) != null) {
	content.append(inputLine);
}
in.close();
con.disconnect();
System.out.println("Response status: " + status);
System.out.println(content.toString());
[{
  "status": "1",
  "articulo_id": 5751,
  "almacen_id": 1,
  "articulo_stock_custom_id": "",
  "info": "Actualizado"
}]
[{
  "status": "0",
  "info": "Motivo del error."
}]

BODY PARAMS

empresa_id // integer (requerido)
sucursal_id // integer (requerido)
almacen_id // integer (requerido)
articulo_stock_cantidad // String
articulo_stock_cantidad_minima // String
articulo_stock_planta // String
articulo_stock_zona // String
articulo_stock_columna // String
articulo_stock_fila // String
articulo_stock_posicion // String
articulo_stock_fecha_add // YYYY-MM-DD H:i:s
articulo_stock_fecha_upd // YYYY-MM-DD H:i:s
articulo_stock_delete // integer
(Opciones: 0 = visible | 1 = eliminado)
articulo_stock_custom_id // String