custom service respond me : 401 Unauthorized: Missing required argument foo

I have this custom service:

function zbs_services_resources() {
  return array(
    'productQuestionForm' => array(
      'actions' => array(
        'send' => array(
          'help' => 'save a FOO entity via send form',
          'file' => array('file' => 'inc', 'module' => 'zbs'),
          'callback' => '_zbs_productQuestionForm_create',
          //'access arguments' => array('note resource create'),
          //'access arguments append' => FALSE,
          'args' => array(
              array(
                'name' => 'foo',
                'type' => 'struct',
                'description' => 'The FOO to create',
                'source' => 'data',
                'optional' => false,
              ),
            ),
        ),
      )
    )

  );
}

And this little jQuery code in a simple html test file:

$.ajax({
    url: "/rest1/productQuestionForm/send",
    headers: { 'Content-Type': 'application/json','X-CSRF-Token':'MY_WORKING_TOKEN' },
    success: function (res) {
      alert("success");
      console.log(res);
    },
    data : {
      'foo' : 'pippo',
      "type":"page",
      "title":"Page submitted via entity JSON REST",
      "body": {
          "value": "

test

n", "format": "filtered_html" } }, type: 'post', dataType: 'json', });

But when I load the simple test html page I see this in developer suite for the POST url:

401 Unauthorized: Missing required argument foo

Where am I doing wrong?

All topic

Create custom post when order is placed

I want to create a custom post of type fundraiser-purchase when payment for an order is successfully completed. I also want to use some of the order details in the post content, including date, value and name of coupon code.

I’m trying to use the following code, but it doesn’t appear to want to work for me, and I’m not sure how to get the name of the coupon?

// Create custom post when placing order
// =============================================================================
function create_fundraiser_purchase_post($order_status, $order_id, $post, $checkout ) {

    $order = wc_get_order( $order_id );

    $order_data = $order->get_data();

    $order_id = $order_data['id'];
    $order_date_created = $order_data['date_created']->date('F j, Y');
    $order_discount_total = $order_data['discount_total'];
    $order_total = $order_data['cart_tax'];

    $title = 'Fundraiser Purchase' . $order_id . $order_date_created;

    $my_post = array(
        'post_title'    => $title,
        'post_content'  => 'Content',
        'post_status'   => 'publish',
        'post_type' => 'fundraiser-purchase'
    );

    $new_post_id = wp_insert_post( $my_post );

}
add_action( 'woocommerce_payment_complete_order_status', 'create_fundraiser_purchase_post', 10, 2 );

Code is loosely based on https://stackoverflow.com/questions/39401393/how-to-get-woocommerce-order-details and https://stackoverflow.com/questions/44977174/get-coupon-discount-type-and-amount-in-woocommerce-orders

Any clues what I might be doing wrong?

All topic

How to display items of all versions in a custom list?

Is there anyway to achieve that? I want a view showing all versions of items in given list.

say:

ID Version Content
 1       1     aaa
 1       2     bbb
 1       3     ccc
 2       1     ddd
 3       1     eee

All topic

shopify draft order custom items – Images

I’ve created an app that uses the shopify draft order api to create a number of custom items based on interactions in the app, so that the customer can checkout their items using shopify.

I’d like to add image thumbnails to the items, ideally just by supplying a URL to the image file, yet I can’t seem to find a way to do this in the API reference. (https://help.shopify.com/en/api/reference/orders/draftorder)

All topic

Import virtual disk to Google Cloud with Custom network

When I try to import a vmdk file to GCP with gcloud compute images import command, I get

“googleapi: Error 400: Invalid value for field ‘resource.networkInterfaces[0]’: ”.

Subnetwork should be specified for custom subnetmode network”.

The subnet mode in default network is set to “CUSTOM”. that’s why I am getting that msg.

Is there a way to specify network when I import the image? or specify the subnet information?

All topic

Deployment custom App in Microsoft Teams

I am developing a chatbot azure service, which I want to integrate within Microsoft Teams.
So far everything is working but the “re-install” of the package in the Microsoft Teams.

I created a publish “folder-profile”. Then I zip the result with the manifest.json and the icon files inside. I go to the Manage Team section and in the Apps tab I select upload a custom app. Then I choose the .zip file and the service seems to be there(Actually it is there)

It works, but when I create a new version and I repeat the described steps, it seems like Microsoft Teams is still using my old code.

I test the chatbot in the Chat by using @”APP-ID” and I see how my changes work, but installed as an App for the “Team” keeps the old version.

I tried to uninstall it, check if the bot is gone(it is gone) and then upload again, but some kind of cache is there and the bot behaves like in the previous version.

Any idea how is the correct way to deploy new versions of my app in Microsoft Teams?

All topic

Magento2 module : Custom option type fields not displaying

I am working on a module to add a product custom option input type (Derivated from file type).

In the backend under catalog / product / custom options, my new option is present in the “input type” list but when I select it, the associated fields are not displayed (Price, price type, sky, compatible file extension, etc).

I do not manage to find what is going on…

Thank you for your help,

My files :

app/code/A/Custoptiontype/etc/module.xml



    
        
            
        
    

app/code/A/Custoptiontype/etc/di.xml



    
    

app/code/A/Custoptiontype/etc/product_options.xml



    

app/code/A/Custoptiontype/Block/Adminhtml/Product/Edit/Tab/Options/Option.php

getCanEditPrice();
        $canReadPrice = $this->getCanReadPrice();

        $this->getChildBlock('xfile_option_type')
            ->setCanReadPrice($canReadPrice)
            ->setCanEditPrice($canEditPrice);
        $templates = parent::getTemplatesHtml() . "n" .
            $this->getChildHtml('xfile_option_type');

        return $templates;    
    }          
}

app/code/A/Custoptiontype/Block/Adminhtml/Product/Edit/Tab/Options/Type/Xfile.php

_optionPrice = $optionPrice;
        parent::__construct($context, $optionPrice, $data);
    }

}

app/code/A/Custoptiontype/view/adminhtml/templates/catalog/product/edit/options/option.phtml



getTemplatesHtml() ?>



isReadonly()): ?>

app/code/A/Custoptiontype/view/adminhtml/templates/catalog/product/edit/options/type/xfile.phtml



TOTOTOTOTO

All topic

Detecting information leakage in Find Sec Bugs via taint analysis and custom annotations

Does Find Sec Bugs allow one to define sensitive sources and sinks via annotations, like other static analysis tools such as the Checker Framework? Right now I only see sources/sinks being defined in config files like so: https://github.com/find-sec-bugs/find-sec-bugs/blob/99814871f33ca0484b975f2fe51bae2bc1bcf40a/plugin/src/main/resources/taint-config/taint-sensitive-data.txt

The Checker Framework has a @Tainted and @Untainted annotation that can be used generically throughout the code (https://checkerframework.org/manual/#tainting-many-uses)

You can also create custom annotations, the documentation shows how it can be applied to the information leakage case (https://checkerframework.org/manual/#subtyping-example)

package myPackage.qual;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

/**
 * Denotes that the representation of an object is encrypted.
 */
@SubtypeOf(PossiblyUnencrypted.class)
@ImplicitFor(literal={LiteralKind.NULL})
@DefaultFor({TypeUseLocation.LOWER_BOUND})
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface Encrypted {}

package myPackage.qual;

import org.checkerframework.framework.qual.DefaultQualifierInHierarchy;
import org.checkerframework.framework.qual.SubtypeOf;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

/**
 * Denotes that the representation of an object might not be encrypted.
 */
@DefaultQualifierInHierarchy
@SubtypeOf({})
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface PossiblyUnencrypted {}

import myPackage.qual.Encrypted;

...

public @Encrypted String encrypt(String text) {
    // ...
}

// Only send encrypted data!
public void sendOverInternet(@Encrypted String msg) {
    // ...
}

void sendText() {
    // ...
    @Encrypted String ciphertext = encrypt(plaintext);
    sendOverInternet(ciphertext);
    // ...
}

void sendPassword() {
    String password = getUserPassword();
    sendOverInternet(password);
}

As a result it’ll spit out something like:

YourProgram.java:42: incompatible types.
found   : @myPackage.qual.PossiblyUnencrypted java.lang.String
required: @myPackage.qual.Encrypted java.lang.String
    sendOverInternet(password);

Anything similar in Find Sec Bugs? Thanks!

All topic

Display attachment as image rather than link in custom list form

I am making a custom list form where the user will input texts and can upload images as attachments. This images will serve as an icon next to the inputted text in the allitems.aspx. How can I make the attachment be viewable as image rather than a link? Any inputs will be much appreciated.

All topic