Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Unable to Upsert #20

Open
passitor opened this issue Apr 2, 2015 · 8 comments
Open

Unable to Upsert #20

passitor opened this issue Apr 2, 2015 · 8 comments

Comments

@passitor
Copy link

passitor commented Apr 2, 2015

I have deployed rest_suite but am unable to use the upsert request. I am trying to update the memo field on a purchase order. Based on the README I have built the following cURL request:

curl -H "Authorization: NLAuth nlauth_account=12345,[email protected],nlauth_signature=mys3cr3tpass,nlauth_role=123" -H "Content-Type: application/json" -d '[{"internalid": "12345", "record_type": "purchaseorder", "literal_fields": {"memo": "test"}}]' https://rest.netsuite.com/app/site/hosting/restlet.nl\?script\=100\&deploy\=1

This fails to make any change to the purchase order record. However, the script appears to return a successful response:

{
    "params": [
        {
            "internalid": "12345",
            "literal_fields": {
                "memo": "test"
            },
            "record_type": "purchaseorder"
        }
    ],
    "success": true
}

If I change the internal ID and record type to nonexistent gibberish, I still get the same success message.

Is there something wrong with the format of the data I am posting, or is the upsert script somehow broken?

@tamagokun
Copy link

Same. @passitor did you ever figure this out?

@wilderuncat
Copy link

I discovered a bug that was causing upsert to fail for me: #23

@passitor
Copy link
Author

That patch did solve my problem. Upsert now works. Here's a working cURL request to update the memo field on an existing purchase order:

curl \
    -H "Authorization: NLAuth nlauth_account=12345,[email protected],nlauth_signature=secretpassword,nlauth_role=123" \
    -H "Content-Type: application/json" \
    -d '{"record_data": [{"internalid": "12345", "record_type": "purchaseorder", "literal_fields": {"memo": "test"}}]}' \
    https://rest.netsuite.com/app/site/hosting/restlet.nl\?script\=100\&deploy\=1

@hayden-t
Copy link

hayden-t commented Apr 24, 2017

It seems the details of the request have to be an element of array 'record_data' , this is not documented in the readme, and im not sure why its even necessary .... also that patch #23 is needed

It should really return a fail or notice result if 'record_data' is not set or empty

@JsbB07
Copy link

JsbB07 commented Mar 7, 2018

hayden-t
Upsert is not working after I made the changes from patch #23.
Could you give an more detail or a simple example of this 'record_data' array?

@hayden-t
Copy link

hayden-t commented Mar 7, 2018

I have uploaded my php helper, which has examples in it that work for me: #38 , bear in mind this is as i use it it with all my modifications as branched by me in the forks page. but have a look it may work still.

@JsbB07
Copy link

JsbB07 commented Mar 8, 2018

Thanks,

I am using Python for the request. I was able to get search.js, saved search.js, load.js, and initialize.js to work, but upsert.js fails. I'm sending it in a format such as:

{
"single record action": {
"record_data": [
{
"internalid": "XXXXX",
"record_type": "inventoryitem",
"literal_fields": {
"itemid": "Test_Inventoryitem2"
}
}
]
}
}

As a test, I'm just trying to alter an existing inventory items record name. I have tried several different versions of the format but nothing works. If I remove ""single record action", Netsuite send back a notice saying missing parameter. I suspect something might still be off in my upsert.js. I altered the original like in #23 and "ephemer" change from the post "JSON examples for subrecords, sublists, etc. #14"

_"_I got the debugger working and found the code in upstream.js should look like this:

UpsertRequest.prototype.loadOrInitializeRecord = function() {
if(this.internalid) {
return NetsuiteToolkit.loadRecord(this.record_type, this.internalid);
} else {
return NetsuiteToolkit.createRecord(this.record_type);
}
}"

Maybe I shouldn't have made both wildkatana and ephemer's changes?

Thanks

@JsbB07
Copy link

JsbB07 commented Mar 8, 2018

Using a Python oauth2 request: I finally got it working with this general format:

{
"record_data": [
{
"internalid": "XXXXX",
"record_type": "inventoryitem",
"literal_fields": {
"itemid": "XXXXXXXX",
"displayname" : "XXXXXXXXX",
}
}
]
}
It alters existing or creates new records...(In case it helps someone else down the road)....

Thanks for the great project!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants