sharepoint online – What is the payload to be sent for “ViewFields” parameter as part of consuming the SPO REST API?

I am trying to create a SharePoint list view through the SharePoint REST API, with a defined set of columns to be part of the view. The endpoint i am using is below:



URL:‘ListName’)/views Headers:

‘Accept’ – ‘application/json;odata=verbose’
‘Content-Type’ – ‘application/json;odata=verbose’
Body (JSON):



I get a JSON error, since this payload does not seem to be right. Need help in understanding how to create a view with specific fields through the SharePoint REST API.

Thanks, Yesh

magento2 – Magento 2 REST Api For Place Order gives “transaction declined” error after successful Payment For Payfort Payment Gateway

I am using Payfort extension to process credit Card Payments online for Payfort Payment Gateway. For Website it’s working Fine and Placing an order after successful payment.

But when i am trying to place an order via API after successful payment via it’s iOs/Android SDK.
It’s giving me this Error.

Transaction has been declined. Please try again later.

This is How i am passing each information i received from Payfort after Successful Payment in this API.




“billingAddress”: {
“city”: “Dubai”,
“countryId”: “AE”,
“customerAddressId”: “2885”,
“customerId”: “3438”,
“fax”: “+971521231234”,
“firstname”: “Test”,
“lastname”: “User”,
“postcode”: “1111”,
“region”: “Dubai”,
“regionCode”: “DXB”,
“regionId”: “597”,
“street”: [
“Street 44, Oud Maitha”
“telephone”: “+971521231234”
“cartId”: “24361”,
“paymentMethod”: {
“additional_data”: {
“amount”: “29995”,
“authorization_code”: “614835”,
“card_number”: “411111******1111”,
“card_holder_name”: “Test User “,
“customer_email”: “”,
“customer_ip”: “”,
“expiry_date”: “2102”,
“fort_id”: “169996200000452654”,
“is_active_payment_token_enabler”: false,
“merchant_reference”: “XXXXXXXX”,
“payment_option”: “VISA”,
“sdk_token”: “c85bf903408b45a19a194710a941607a”,
“token_name”: “82f62b316c3246908ba29c8f2e683f45”
“method”: “md_payfort”

I am getting “True” in the response of this API call.

Then, I am using Create Order API of Magento to Place an Order.




“paymentMethod”: {
“method”: “md_payfort”
“shippingMethod”: {
“additionalProperties”: {},
“carrier_code”: “freeshipping”,
“method_code”: “freeshipping”

After debug, i found that this error is coming from this file.


And it’s because the “execute” method in this class is sending the Payment request again to Payfort and they recieve the “Signature mismatch” error from Payfort because of the unauthorized request. It should not send the Payment request again to Payfort.
I am not able to figure out how to prevent Magento to make this Payment request and just Place the Order.

If anyone can help me out to solve this problem and place an order successfully would be really appreciated.

javascript – Dynamic REST Statements

Is there a way to dynamically create a REST call and specifically I am referring to the data: section of the call. If I get the terminology incorrect by all means keep me honest. I tried some things with no success. I looked at the __metadata portion and thought this was a key/value pair and tried some substitution with no luck. Same for the field:value pairs. Been poking around on stack to try to find something with no luck so far.

So, in the following REST example is there a way to “break out” the information following the __metadata in the brackets and also the field:value immediately after the brackets.

    type: 'POST',
    url: odataUrl, 
    contentType: "application/json;odata=verbose",
    processData: false,
    headers: {
            "Accept": "application/json;odata=verbose",
            //"If-Match": "*", 
            //"X-HTTP-Method": "MERGE"
    data: JSON.stringify(
        __metadata :{
        modname:'no name'**


I tried using the following with no luck as an example setting the variables outside the REST statement and replacing the metadata statement with the following vars.

var typetest={"type":"SP."+TargetListName+"ListItem"};
var savetst={Title:"projname",ver:'test',modname:'browsertest'};
     data: JSON.stringify(
          __metadata :{typetest},savetxt

Thanks for the help.

vue.js – Django REST Api does not allow Vus.js access for restricted pages

I have configured the apache2 for django and I’m developing an app with Vue.js. When both are running as dev servers everything works fine. But when I try to access the django views when running with apache2 it gives following error for any authenticated page.

[Tue Nov 24 03:58:21.593868 2020] [wsgi:error] [pid 1206] [remote] Unauthorized: /profile/
[Tue Nov 24 03:58:39.133313 2020] [wsgi:error] [pid 1206] [remote] Unauthorized: /search/

SharePoint REST API Get Choice Dropdown Index

I have a dropdown with 5 string values.

I can use following request to get string values of the dropdown for every list item


Result is returned with this property


“Moderate” is at index 4 in the dropdown list, can I get that index instead of text value?

sharepoint rest api – how to add value in document library look up column when button is clicked

function UpdateDocsDetails() {
  var def = jQuery.Deferred();
  var itemPayload = "";
  var restSource = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('DMSDocs')/Items(" + lastItem + ")";
  itemPayload = { "__metadata": { "type": "SP.Data.DMSDocsItem" }, "RequestID": _reqID};
  var dfd = jQuery.Deferred();
      url: restSource,
      method: "POST",
      contentType: "application/json;odata=verbose",
      data: JSON.stringify(itemPayload),
        "Accept": "application/json;odata=verbose",
        "X-RequestDigest": jQuery('#__REQUESTDIGEST').val(),
        "X-HTTP-Method": "MERGE",
        "If-Match": "*"
      success: function (data) {
        // alert("Success");
      error: function (err) {
        // alert("Error:");
  return dfd.promise();

this function is need to update the lookup column RequestID

function SaveDeferred(action) {
    var dialog = bootbox.dialog({
      title: 'Saving.......',
      message: '<p>Saving... <i class="fa fa-spin fa-spinner"></i></p>',
      closeButton: false
    var c = CheckForAttachment();
    if (c == true) {
      var p = createItem(action);
      p.done(function (res) {
        if (UpdateFlag == 0) {
          _reqID = res.get_id();
        var d = UpdateDocsDetails();
        d.done(function (_reqID) {
          console.log('Item created successfully!');
          if (UpdateFlag == 0) {
            var _nextNo = GetNextNumber();
            _nextNo.done(function (result___nextNo) {
              var Series = result___nextNo.d.results(0).Series;
              var StartingValue = result___nextNo.d.results(0).StartingValue;
              var LastUsedValue = parseInt(result___nextNo.d.results(0).LastUsedValue);
              if (LastUsedValue == 0) {
                LastUsedValue = LastUsedValue + 1;
              } else {
                LastUsedValue = LastUsedValue + 1;
              var _update_Title = UpdateTitle(_reqID, Series, LastUsedValue);
              _update_Title.done(function (result__updated) {
                var _udp_NoSeries = UpdateNextNumber(Series, LastUsedValue);
                _udp_NoSeries.done(function (result___udp_NoSeries) {
                  var msg = "Your request Submitted successfully!!";
                  bootbox.alert(msg + " Your request No is " + result__updated, function () {
                    window.location.replace("/sites/" + siteName + "/SitePages/DMSApprovedRequests.aspx");
       (result__udp_NoSeries) {
                console.log("Your request sent successfully!! Your request No is " + result__updated);
     (result__updated) {
   (result___nextNo) {
          else {
            bootbox.alert("Your request sent successfully!!", function () {
              window.location.replace("/sites/" + siteName + "/SitePages/DMSApprovedRequests.aspx");
      }); (ex, error) {
        console.log(ex + " " + error);
    else {
      return false;

this function when item saved in SharePoint list but my Page is stuck on saving dialog after UpdateDocs Details() called but not going further to next number update in function

rest api – Will http caching using WP_REST_Response() be specific to the data that is requested?

If I have data being requested, and the response is dependent on the data requested, would the following sample code cache all responses the same, or would it somehow know “you requested a response for $data with X values, so we are only caching a response for data with X values?

Basically my callback function should be returning the same response only if the same data is requested.

Sample code:

register_rest_route('wp/v2', '/my_endpoint', array(
'methods' => 'GET',
'callback' => 'function_callback',

function function_callback($data) {

// this response would be different depending on the $data requested
$response = functionThatUtilizesInputData($data);

$result = new WP_REST_Response($response, 200);

// Set headers.
$result->set_headers(array('Cache-Control' => 'max-age=3600'));

return $result;

rest – How do I delete a comment?

Actually I have problems with deleting a comment via REST in Drupal 8.99 and 9.0.7. I have no problem when using a POST, PATCH, or GET requests. Otherwise, I get this error.

Path: /c24102020/comment/51418?_format=hal_json. SymfonyComponentHttpKernelExceptionAccessDeniedHttpException: in DrupalCoreRoutingAccessAwareRouter->checkAccess() (line 120 of /var/www/html/c24102020/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

My end-point is http://localhost/c24102020/comment/51418?_format=hal_json.

The headers for the request are the following.

  • X-CSRF-Token
  • Content-Type: application/hal+json
  • Accept: application/hal+json
  • Authorization: Basic cm9vd….

The body request is empty.

I use ResTer and I get a 403 Forbidden error.

rest api – Get custom posts in gutenberg block

I am quite new to block development and react. I am trying to make a block which shows a list of custom posts of choice. I as able to create attributes to save user preferences like post type, count, status, etc. Now I want to fetch the posts. Where I am not sure if should use php endpoint or WP JSON API to fetch posts? I saw in may places they are either using some custom php endpoint or just using the render_callback to call php function which takes care of fetching and showing posts. Is there any downsides using the REST API with JS rather than fetching in good old WP_Query way?

import './editor.scss';
import './style.scss';

const { __ } = wp.i18n; // Import __() from wp.i18n
const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks

registerBlockType( 'cgb/block-myposts', {
    title: __( 'myposts - CGB Block' ),
    icon: 'shield',
    category: 'common',
    keywords: (
        __( 'myposts — CGB Block' ),
        __( 'CGB Example' ),
        __( 'create-guten-block' ),

    edit: ( props ) => {
        // I want to fetch posts here and show

    save: ( props ) => {
        return null;
} );