Sample code for 30+ languages & platforms
DataFlex

Akeneo: Create New Attribute Group

See more HTTP Misc Examples

Demonstrates how to create a new attribute group.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vJson
    Handle hoJson
    String sUrl
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1

    Move False To iSuccess

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Use your previously obtained access token.
    // See Get Akeneo Access Token
    Set ComAuthToken Of hoHttp To "access_token"

    // Build the following JSON to be sent in the request body:
    // Use this online tool to generate the code from sample JSON: 
    // Generate Code to Create JSON

    // {
    //   "code": "marketing",
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "code" "marketing" To iSuccess

    Set ComEmitCompact Of hoJson To False
    // Show the JSON to be sent..
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    Move "http://pim.my-akeneo-site.com/api/rest/v1/attribute-groups" To sUrl
    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoJson to vJson
    Get pvComObject of hoResp to vResp
    Get ComHttpJson Of hoHttp "POST" sUrl vJson "application/json" vResp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Success is a 201 response status code with an empty body.
    Get ComStatusCode Of hoResp To iTemp1
    Showln "Response Status Code: " iTemp1
    Showln "Response Body: "
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1


End_Procedure