Forum Discussion

DonLarson's avatar
DonLarson
Qrew Commander
13 days ago
Solved

Pipeline API Post

I am using a Pipeline to create a single record in a table with a Post Method from a Make a Request step.   I cannot use a Create Record Step as the number of possible destination tables is too large.  

After much trial and tribulation that is working now.    The next piece of my workflow I need the Record ID from the record just created.   The REST API logic says to use a 

'fields ToReturn '

Looking at the Activity I can see that the RID is getting back to the Pipeline.  However I do not know how to use it inside of the Pipeline in a future Step.

Any suggestions from the Python/ JSON and Jinja wizards?

 

 

  • If you are looking to parse a JSON response in a Pipeline and you know where and what value are looking for there is a simple way to get to a specific piece of data.  Credit for this goes to Jenny on the QB Support Team for getting me the solution.

    There are five parts to the Jinja Expression

    • The STEP that the JSON is resident in
    • The SECTION of the JSON to get
    • What part of the ARRAY to get
    • The FIELD to get 
    • The value

    Here is the expression

    {{STEP.json.SECTION[ARRAY]['FIELD'].value}}

    So here is what my JSON looked like

    { 'data': [{'3': {'value': 14}}],

     'metadata': {'updatedRecordIds': [],

     'createdRecordIds': [14],

    'unchangedRecordIds': [],

    'totalNumberOfRecordsProcessed': 1}}

    {createdRecordIds}

    }

    This is a really small array.  In the 'data' section is only one piece of data for FID3 and its value is 14.   That is what I wanted to get.

    So my working Jinja Expression is 

    {{b.json.data[0]['3'].value}}

    • The JSON was coming from Step B.  
    • data is the section I want to get something from.  There is another on it called metadata but I am not interested in those at the moment.
    • 0 is the first part of the array. If your JSON returns ten records JSON counts to ten by going:
      •  0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    • 3 is the name of the information I want.   The real world case here is that I asked for the value of FID 3.  In QB the name of the field would be Record ID but the name is not what got returned it was the FID
    • value  tells it to give me the value for '3'  

    The answer that the Pipeline Step kicks out is

    14

    which is exactly what I needed for the next part of my problem.

    If you have large arrays, need to search for data or manipulate the result further, this is probably not helping much.  If you know where and what you want to pull from the JSON, it will do the trick.

     

2 Replies

  • DonLarson's avatar
    DonLarson
    Qrew Commander

    If you are looking to parse a JSON response in a Pipeline and you know where and what value are looking for there is a simple way to get to a specific piece of data.  Credit for this goes to Jenny on the QB Support Team for getting me the solution.

    There are five parts to the Jinja Expression

    • The STEP that the JSON is resident in
    • The SECTION of the JSON to get
    • What part of the ARRAY to get
    • The FIELD to get 
    • The value

    Here is the expression

    {{STEP.json.SECTION[ARRAY]['FIELD'].value}}

    So here is what my JSON looked like

    { 'data': [{'3': {'value': 14}}],

     'metadata': {'updatedRecordIds': [],

     'createdRecordIds': [14],

    'unchangedRecordIds': [],

    'totalNumberOfRecordsProcessed': 1}}

    {createdRecordIds}

    }

    This is a really small array.  In the 'data' section is only one piece of data for FID3 and its value is 14.   That is what I wanted to get.

    So my working Jinja Expression is 

    {{b.json.data[0]['3'].value}}

    • The JSON was coming from Step B.  
    • data is the section I want to get something from.  There is another on it called metadata but I am not interested in those at the moment.
    • 0 is the first part of the array. If your JSON returns ten records JSON counts to ten by going:
      •  0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    • 3 is the name of the information I want.   The real world case here is that I asked for the value of FID 3.  In QB the name of the field would be Record ID but the name is not what got returned it was the FID
    • value  tells it to give me the value for '3'  

    The answer that the Pipeline Step kicks out is

    14

    which is exactly what I needed for the next part of my problem.

    If you have large arrays, need to search for data or manipulate the result further, this is probably not helping much.  If you know where and what you want to pull from the JSON, it will do the trick.

     

  • DonLarson's avatar
    DonLarson
    Qrew Commander

    If you are looking to parse a JSON response in a Pipeline and you know where and what value are looking for there is a simple way to get to a specific piece of data.  Credit for this goes to Jenny on the QB Support Team for getting me the solution.

    There are five parts to the Jinja Expression

    • The STEP that the JSON is resident in
    • The SECTION of the JSON to get
    • What part of the ARRAY to get
    • The FIELD to get 
    • The value

    Here is the expression

    {{STEP.json.SECTION[ARRAY]['FIELD'].value}}

    So here is what my JSON looked like

    { 'data': [{'3': {'value': 14}}],

     'metadata': {'updatedRecordIds': [],

     'createdRecordIds': [14],

    'unchangedRecordIds': [],

    'totalNumberOfRecordsProcessed': 1}}

    {createdRecordIds}

    }

    This is a really small array.  In the 'data' section is only one piece of data for FID3 and its value is 14.   That is what I wanted to get.

    So my working Jinja Expression is 

    {{b.json.data[0]['3'].value}}

    • The JSON was coming from Step B.  
    • data is the section I want to get something from.  There is another on it called metadata but I am not interested in those at the moment.
    • 0 is the first part of the array. If your JSON returns ten records JSON counts to ten by going:
      •  0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    • 3 is the name of the information I want.   The real world case here is that I asked for the value of FID 3.  In QB the name of the field would be Record ID but the name is not what got returned it was the FID
    • value  tells it to give me the value for '3'  

    The answer that the Pipeline Step kicks out is

    14

    which is exactly what I needed for the next part of my problem.

    If you have large arrays, need to search for data or manipulate the result further, this is probably not helping much.  If you know where and what you want to pull from the JSON, it will do the trick.