jquery ajax – Add items to Sharepoint Online's modern user interface list using the API

When you use SharePoint Framework to develop and build custom WebParts code, you can (and should) use the context provided in the parent WebPart component this.context and send it via its properties to your root WebPart component (the rendered ones).

Now your component has the context and capabilities to use the provided SPHttpClient, which does the authentication and work for you: this.props.context.spHttpClient. with the methods get(). post() and fetch(),

If you are not using SharePoint Framework now, you are on a SharePoint page where you can no longer retrieve a request digest (and need one to transfer data). You must first ask for one and use it in a X-RequestDigest Headers in your mail requests.

The Office365 app page does not contain a RequestDigest

The method is to create a first POST /_api/contextinfo,

Hope that helps!

asp.net Web API – Angular POST Form

I am using an API break and need a form to add existing cities: Ciudad.module.ts, ciudad.service.ts. I'm using the POST method to get the user and token

Stadt.Modul.ts:

export class Ciudad {
id: number;
nombre: string;
poblacion: string;

}

Stadt.Service.ts

readonly ciurl = "https://localhost:44359/api/ciudad";
  constructor(private http: HttpClient, private   authSession: UserService) 
{ }


 setUserLoggedIn(){
  localStorage.getItem('Token');
  alert("token");
  }
}

This is the home.ts
Constructor (private service: CiudadService) {}

  ngOnInit() {

    var  token = localStorage.getItem('Token');
    var user = localStorage.getItem('Username');

}

resetForm(form?: NgForm){
  if(form!= null)
  form.resetForm();
  this.service.formData = {
    id : null,
    nombre : '',
    poblacion : ''
  }
}
onSubmit(form : NgForm){
  const newcuidad : CiudadService = Object.assign({}, this.service);
}

}

And that's the shape

   
This Field is required.
This Field is required.
This Field is required.

I would like to know how to get POST working with this form

Javascript – Use the Dropbox API to retrieve the latest file from the Github Pages site

I am currently trying to use the Dropbox API in a Github Web site to retrieve the most recent file in Dropbox and use its title to change the CSS background color. However, I can not figure out how to write the js to use the Dropbox API. I have the access token that I replaced in the code I specified with Insert_Access_Token_Here. The following is a test that should print my files in the console, but not. Can anyone tell me from scratch how to use the Dropbox API to at least get the name of the latest file? Many thanks


The error message I keep getting in the console is

net :: ERR_ABORTED 404

Input and paging specification patterns for API classes in Net Core

I read the following website and created a PageModel and a specification pattern. The question is, should I merge these two for good practice or keep them separate?
The PageModel accepts the following parameters in a pagination URL API. So 100 products, you can see 10 products per page.

localhost/api/Products?Page3&Limit=10

https://dejanstojanovic.net/aspnet/2019/january/filtering-and-paging-in-aspnet-core-web-api/

public class PageModel
{
    public int Page { get; set; }
    public int Limit { get; set; }
    public string ColumnSort { get; set; }

    public object Clone()
    {
        var jsonString = JsonConvert.SerializeObject(this);
        return JsonConvert.DeserializeObject(jsonString, this.GetType());
    }
}

In addition, a specification pattern was created that works with the domain driven design (DDD) and the company's generic repository (the company's architect wanted the generic repository, not my call).

public class Paged : IPaged
{
    private readonly IQueryable source;

    public Paged(IQueryable source)
    {
        this.source = source;
    }

    public IEnumerator GetEnumerator()
    {
        return source.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }

    public int Count
    {
        get { return source.Count(); }
    }

    public IEnumerable GetPage(int index, int limit)
    {
        if (index <= 0 || limit <= 0)
        {
            return source;
        }
        else
        {
            return source.Skip((index - 1) * limit)
                .Take(limit);
        }
    }

    public IEnumerable GetPage(int index, int limit, IEnumerable orderMembers, ListSortDirection sortOrder)
    {
        return source.OrderByMembers(orderMembers, sortOrder)
            .Skip((index - 1) * limit)
            .Take(limit);
    }

    public T GetFirst(Expression> whereLambda)
    {

        return source.Where(whereLambda).FirstOrDefault();
    }

    public IEnumerable GetAll()
    {
        return source.ToList();
    }
}

When reading a number of websites, the question is whether I still need the first page model, or whether it is better to include it in the following page specification pattern. It seems as if it would clean up / simplify the code, not sure if it violates the SRP principle of individual responsibility.

If they were merged, we would need to put the paged pattern in the URL parameter. If we then make other methods available, we are not sure if this is safe or not, we probably do not guess.

Current implementation:

API Controller

    (HttpGet)
    (ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK))
    public ActionResult>> Get((FromQuery) PageModel pageModel)
    {
        ProductRequest productRequest = new ProductRequest();
        productRequest.pageModel = pageModel;
        return Ok(productAppService.GetAllProducts(productRequest));
    }

App Business Service Layer:

    public IEnumerable GetAllProducts(ProductRequest productRequest)
    {
        var productspaged = new Paged(productRepository.GetAll()).GetPage(productRequest.pageModel.Page, productRequest.pageModel.Limit);

        IEnumerable productModel = mapper.Map>(productspaged);
        var productDto = mapper.Map, IEnumerable>(productModel);
        return productDto;
    }

Notes on pagination

windows – Error interacting with the REST API The user does not have the bigquery.datasets.create privilege in the project

I'm trying to use Simba Bigquery ODBC driver to extract some data into an external database. While the connection works fine and I can see the project tables, I can not run my SQL. The query works fine in an online cloud environment.
Everyone knows why the bug in the bigquery.datasets.create privilege occurs and how it can be fixed.

mcd – DDD with Web API, validation in domain or application layer?

I have seen many discussions, but I do not know how to do that in a real world.
I understand that validation duplication is required on the client and the server.
But how to elegantly validate in the server and return friendly messages to the client.

I have a value object like this, it has some business rules.

public class OrderId : ValueObject
{
    public string Value { get; }

    public OrderId(string value)
    {
        if (string.IsNullOrWhiteSpace(value) || value.Length > 50)
        {
            throw new ArgumentException(nameof(value), "error message here");
        }

        Value = value;
    }
}

The command sent by the client.

public class CreateInvoiceCommand : IRequest
{
    public string OrderId { get; set; }
}

The application layer creates a value object. However, if the command violates business rules, an exception is thrown. This is not friendly for the client. Imagine, there are more business rules here. Only the first rule is returned.

public class CreateInvoiceCommandHandler : IRequestHandler
{
    public Task Handle(CreateInvoiceCommand command, CancellationToken cancellationToken)
    {
        var orderId = new OrderId(command.OrderId);

        return Task.FromResult(Unit.Value);
    }
}

So I validate the command when the request arrives. With FluentValidation, user-friendly messages can be returned to the client.

public class CreateInvoiceCommandValidator : AbstractValidator
{
    public CreateInvoiceCommandValidator()
    {
        RuleFor(c => c.OrderId).NotEmpty().MaximumLength(50);
        //Other rules...
    }
}

My question is, is there any way to solve the duplication and return friendly messages?

Should I remove the business rules in the value object to avoid DRY, is this still DDD?