php – Como fazer uma requisição para uma api rest sem o Postman ou outro programa de teste?

Como fazer uma requisição para uma api rest ?eu já tenho uma api rest pronta, e já testei utilizado postman, no entanto, não sei como fazer essa requisição sem o Postman, direito no código, isso é, eu informo os dados do POST, e faço a requisição do tipo POST… Procurei na internet e não encontrei exatamente isso, só mostra pessoas usando o Postman ou outro programa de teste, mas eu queria saber como fazer a requisição direito no código – no meu caso, com PHP… Alguém pode me indicar um link sobre o assunto ?

development – Is there a way to save a site in SharePoint online as a template programmatically (with an API, PowerShell, C#, etc.)?

I have a SharePoint Online site that has custom scripts enabled, and I want to programmatically save it as a template. I do not want to use PnP Provisioning Templates, I want to access the same functionality as savetmpl.aspx but programmatically. I know that in SharePoint Server you can use the SPWeb.SaveAsTemplate method in PowerShell or C#, but this is not present in SharePoint Online. Is there a way to do this?

I also found the following url: https://mytenant-admin.sharepoint.com/_vti_bin/sites.asmx. I see ExportWeb listed there. Would this work in SharePoint Online?

I looked at this question, but I do not want to use PnP Provisioning

python – ¿cuáles son buenas practicas para manejar zonas horarias, marcas de tiempo, fecha y hora en API y aplicaciones?

Soy relativamente nuevo en esto del backend, estoy trabajando en una aplicación que almacena varios registros de usuarios con campos como created_at y updated_at ambos campos son de tipo timestamp, también estoy seguro que se estan almacenando con la hora UTC.

Estoy realizando muchas consultas a la base con filtros de tiempo, por ejemplo:
todos los usuarios que se actualizaron el dia de hoy.
todos los usuarios creados en el mes.

El problema es que existe un desfase de 5 horas en mis query’s y siempre me trae información diferente a la esperada.

Me gustaría saber cual es la manera profesional de resolver este problema; si es un acuerdo entre frontend y backend o solo trabajo del backend.

lo que necesito es información sobre buenas practicas para esta clase de situaciones

networking – Rest api call taking 50 seconds on the client’s server, but on ours it takes milliseconds

We have a lamp stack. In our office, the code is deployed on a centos 6, we get a response after 1612ms and everything is good.

We deploy the code to our client who’s using centos 7. Postman response time is between 22s and 50s. According to postman “transfer start” takes the longest. I’ve enabled gzip, nothing changed. The response has only 2 parameters, “auth” and “msg”. We call the API over https

The client’s server is located behind a forticlient VPN and they use a Nginx proxy. They control those two, our server is in their datacenter.

Forticlient doesn’t affect the speed because I tried calling the API using curl by SSH to the server and then calling it like this

example.com/api.php and localhost/api.php, both had the same slow response time 41s.

What could the issue be? Could Nginx slow it that much? SElinux is disabled.

8 – Exception handling for incorrect content type for request in custom REST API plugin

I have created a custom REST API plugin for an endpoint. I have set the accepted format to json using the configuration options. This works. However, if we set the content-type to something other than application/json I am getting a 500 error.

I am seeking to know how this exception can be handled more gracefully. However, what is preventing this is the fact that I am not able to get the Request object in the plugin code.

I tried extending the default EventSubscriber services but they do not seem to be of help. I am seeing that this seems to be an open issue in Drupal.org

https://www.drupal.org/project/drupal/issues/2954286

I am thinking of altering the route and set the default format to json as in manually added custom routes but open to better ways.

Any help would be appreciated.

c# – Conexión con la Api de Zendesk

quiero hacer una conexión con Zendesk para crear un ticket, ya tengo creado mi formulario, estoy trabajando con Visual Studio y mi proyecto es de tipo Aplicación Web ASP.NET (.NET FRAMEWORK) y estoy intentando usar HttpWebRequest, en la autenticación quiero hacerlo por medio de un token (su estructura es más o menos así lrVG63Ftyucm24uydWfgcQWdfgEtfC45) pero no he encontrado cómo hacerlo, así que lo estaba haciendo poniendo un correo y contraseña de usuario, pero si me pueden ayudar a hacerlo con token se los agradecería mucho, esto es lo que se debe ejecutar al momento de hacer clic en el botón de enviar:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.IO;
using System.Net;
using System.Text;


namespace Formulario.Public
{
public partial class SendTicket : System.Web.UI.Page
{
 
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void SendButton_Click(object sender, EventArgs e)
    {
        saludo.Text = "datos enviados";
        ValidacionModel jsonObject = new ValidacionModel();
        jsonObject.request = new Request() {
            email = "prueba@correo.com",
            name = "Ana",
            classification = "Facturación",
            subject = "Test",
            description = "test sndndddjiwd djw"
        };

        // Json conversion
        JsonSerializerSettings settings = new JsonSerializerSettings();
        settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        string jsonTicket = JsonConvert.SerializeObject(jsonObject, settings);

        string postData = jsonTicket;
        byte() byteArray = Encoding.UTF8.GetBytes(postData);

        HttpWebRequest request;
        request = WebRequest.Create("https://prueba.zendesk.com/api/v2/requests.json") as HttpWebRequest;
        request.Timeout = 10 * 1000;
        request.Method = "POST";
        request.ContentLength = byteArray.Length;
        request.ContentType = "application/json; charset=utf-8";

        string credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("prueba@correo.com:password123"));
        request.Headers.Add("Authorization", "Basic " + credentials);

        Stream postStream = request.GetRequestStream();
        postStream.Write(byteArray, 0, byteArray.Length);

        HttpWebResponse response = request.GetResponse() as HttpWebResponse;
        StreamReader reader = new StreamReader(response.GetResponseStream());
        string body = reader.ReadToEnd();

    }
  }
}

Al momento de ejecutar el proyecto me manda el siguiente error:
descripción del error

8: Search API : Elastic Search gives priority to sort instead of title

I am using below modules for Search module:

drupal/elasticsearch_connector": "^5.0@alpha"
drupal/search_api: "^1.8"

I am using AWS Elastic Search.

What the issue I am facing is, the search result giving priority to sort instead of title.

I am using version 6.3 for elastic search. I cannot upgrade the module or Elastic Search module version due to custom dependency.

Example:

https://search-XXXXXXXXXX.ap-southeast-1.es.amazonaws.com/elasticsearch_index_drupal_product_index/_search?source={“query”:{“bool”:{“should”:[{“multi_match”:{“query”:”Test
item”,”fields”:[“title.suggestion”],”fuzziness”:1}}]}},”size”:12,”sort”:[{“field_x”:”asc”,”field_y”:”desc”}]}&source_content_type=application/json

If I have above URL then in the result it will give first priority to field_x then field_y instead of which matches to Test item

So if user is going to search with Product title, then he never get the match product at first place.

In search

admin/config/search/search-api/index/drupal_product_index/processors

  • Ignore case, Stemmer -> I didn’t enabled
  • Tokenizer -> Enabled with
    default settings for all fields

Am I missing something in configiration?

8 – Search API group by issue with views

I have a content type thats is called course which has a field that is a reference to a taxonomy called category.

My specification tells to build a search where users can search for the course title, category and other fields that the course type has. The search functions like intended and everything works great except the display view. Here is my setup:

  • Drupal 8.5
  • Search Api with DB / Solr Backend. (tried both)

So to come back: each course can have multiple categorys to be in which means that the view has to be grouped by the category. If I do that my view displays this:

Category 1 Name

Category 1 Name, Category 2 Name

Category 2 Name

Category 3 Name, Category 2 Name

Category 3 Name

  • Course 7
  • Course 8
  • Course 9

As you can see courses that belong to multiple categorys are not listed underneath the respected category instead they are seperated by a comma. My goal is this:

Category 1 Name

  • Course 1
  • Course 2
  • Course 3

Category 2 Name

  • Course 3
  • Course 4
  • Course 5
  • Course 6

Category 3 Name

  • Course 6
  • Course 7
  • Course 8
  • Course 9

such behaivor is easy to do if you dont use search api and want just to display a normal view. I have already read this issue but it seems my goal is not possible.

I’m asking now here if something has changed or if its possible to get this done with writing custom code? Maybe tell search api to return every result and display them with custom code grouped by the categorys? Can anyone point me to the right direction?