meta data de esta página
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
codigo_java_dominicana [2023/12/13 20:59] 179.63.109.4 |
codigo_java_dominicana [2024/03/20 02:31] (actual) 47.128.30.61 se ha restaurado la vieja versión (2023/11/13 19:08) |
||
---|---|---|---|
Línea 15: | Línea 15: | ||
public static void main(String[] args) throws IOException { | public static void main(String[] args) throws IOException { | ||
String url = " | String url = " | ||
- | String json = " | + | String json = " |
HttpClient httpClient = HttpClientBuilder.create().build(); | HttpClient httpClient = HttpClientBuilder.create().build(); | ||
Línea 27: | Línea 27: | ||
} | } | ||
} | } | ||
+ | |||
</ | </ | ||
- | < | + | < |
- | import | + | import |
- | import | + | import |
- | import org.apache.http.client.methods.HttpPost; | + | |
- | import org.apache.http.entity.StringEntity; | + | |
- | import org.apache.http.impl.client.HttpClientBuilder; | + | |
- | import java.io.IOException; | + | respjson={" |
- | public class Main { | + | j={" |
- | public static void main(String[] args) throws IOException { | + | response = requests.post("https:// |
- | String url = " | + | |
- | String json = "{\"token\": | + | |
- | HttpClient httpClient = HttpClientBuilder.create().build(); | + | print(" |
- | | + | print(response.json()) # |
- | | + | print(" |
- | request.addHeader(" | + | respjson=json.dumps(response.json()) |
- | | + | print(respjson.capitalize()) # |
+ | </ | ||
- | HttpResponse response | + | <code python Enviar> |
- | | + | import requests |
- | } | + | import json |
+ | |||
+ | respjson={" | ||
+ | |||
+ | #Creamos una factura json | ||
+ | |||
+ | j={ | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | }, | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
} | } | ||
- | </ | ||
- | <code java Enviar> | ||
- | import org.apache.http.HttpResponse; | ||
- | import org.apache.http.client.HttpClient; | ||
- | import org.apache.http.client.methods.HttpPost; | ||
- | import org.apache.http.entity.StringEntity; | ||
- | import org.apache.http.impl.client.HttpClientBuilder; | ||
- | import java.io.IOException; | + | # |
+ | response = requests.post(" | ||
- | public class Main { | ||
- | public static void main(String[] args) throws IOException { | ||
- | String url = " | ||
- | String json = " | ||
- | HttpClient httpClient = HttpClientBuilder.create().build(); | ||
- | HttpPost request = new HttpPost(url); | ||
- | StringEntity params = new StringEntity(json); | ||
- | request.addHeader(" | ||
- | request.setEntity(params); | ||
- | HttpResponse response = httpClient.execute(request); | ||
- | System.out.println(response); | ||
- | } | ||
- | } | ||
+ | print(" | ||
+ | print(response.json()) #Imprimimos el resultado en json | ||
+ | print(" | ||
+ | respjson=json.dumps(response.json()) | ||
+ | print(respjson.capitalize()) # | ||
</ | </ | ||