I am using POSTMAN Client and trying to read data from csv file. As a PoC, I have used below end point url
https://www.googleapis.com/books/v1/volumes?q=Light In August
Below is my code
tests["Status code is 200"] = responseCode.code === 200;
postman.setEnvironmentVariable("requestBook", data.requestBook);
var response = JSON.parse(responseBody);
tests["Validate the title is correctly populated"] = /{{title}}/.test(response.items[0].volumeInfo.title);
tests["Validate the author is correctly populated"] = /{{authors}}/.test(response.items[0].volumeInfo.authors);
tests["Validate the publisher is correctly populated"] = /{{publisher}}/.test(response.items[0].volumeInfo.publisher);
tests["Validate the published date is correctly populated"] = /{{publishedDate}}/.test(response.items[0].volumeInfo.publishedDate);
tests["Validate the page count is correctly populated"] = /{{pageCount}}/.test(response.items[0].volumeInfo.pageCount);
tests["Validate the category is correctly populated"] = /{{categories}}/.test(response.items[0].volumeInfo.categories);
tests["Validate the amount is correctly populated"] = /{{amount}}/.test(response.items[0].saleInfo.listPrice.amount);
tests["Validate the currency code is correctly populated"] = /{{currencyCode}}/.test(response.items[0].saleInfo.listPrice.currencyCode);
It is failing. When i check my csv file, its all looks fine
Note: When I click the preview all my data shows with double quoted
I have found the solution hence its resolved. The new code is tests["Validate the title is correctly populated"] = response.items[0].volumeInfo.title === data.title;
Related
I am running a script to pull a weekly schedule excel file attached to an email and posting it to a google sheet. Currently I'm triggering it manually. The code appears to be working correctly and goes to completion based on logger statements but it gives this error code each time.
Document <Sheet ID> is missing (perhaps it was deleted, or maybe you don't have read access?)
The referenced sheet ID is not the sheet i'm working on so i presume it's the temporary document that's been created and deleted. I'm not sure how to get rid of this error. Again, the code appears to be working as intended despite the error.
function getExcelFile()
{
var thread = GmailApp.getUserLabelByName("Guelph/Weekly Schedules").getThreads(0,1);
//var thread = GmailApp.getUserLabelByName(‘Reconciliation’).getThreads(0,1);
var messages = thread[0].getMessages();
var len = messages.length;
var message = messages[len-1] //get last message
var attachments = message.getAttachments(); // Get attachment of first message
var xlsxBlob = attachments[0]; // Is supposes that attachments[0] is the blob of xlsx file.
var convertedSpreadsheetId = Drive.Files.insert({mimeType: MimeType.GOOGLE_SHEETS}, xlsxBlob).id;
var sheet = SpreadsheetApp.openById(convertedSpreadsheetId).getSheets()[0]; // There is the data in 1st tab.
var data = sheet.getDataRange().getValues();
var sheet = SpreadsheetApp.openById("1e_pepsold-SHbnDXcQ0pvdN9AGiZ31O5XcLFU8YfcwE").getSheetByName("Current");
//var sheet = SpreadsheetApp.openById("some id").getSheetByName(‘Data’);
sheet.clearContents();
var range = sheet.getRange(1, 1, data.length, data[0].length);
range.setValues(data);
Drive.Files.remove(convertedSpreadsheetId); // Remove the converted file.
Logger.log(new Date().getTime() - start); // Outputs time taken to run function
}
This looks like a recurring problem; there is already a thread here: Drive.Files.remove(fileId) remove the item but return an error message
My best guess is when the script removes the file, it still uses that same file, so the script returns an error message that the recently removed file is missing.
I know this may not be the best workaround, but you can move the file to Trash instead of deleting immediately:
Drive.Files.trash(convertedSpreadsheetId);
Then you can empty the Trash manually or do it in GAS using:
Drive.Files.emptyTrash();
References:
Trash
Empty Trash
I am trying to add an Image to an Email Body.
I am using Outlook 16 and Python 3.7 to do this.
The mail gets sent from Mailbox.
Here is my code function to send email and how can I add an Image at the end of the email.
def send_email(sender,recipient):
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = Subject_Req
mail.HTMLBody = Content_Email
mail.SentOnBehalfOfName = sender
mail.GetInspector
mail.Send()
The Image is present in my local network :- C:\Users\Sid\AppData\Roaming\Microsoft\Signatures\My Project\image001.png
The Image is nothing but the logo which I want to put at the last part of the HTML body.
So basically from the function it will be Content_Email + This image.
I tried some code, what it does is :- it sends an "X" mark at the end in place of the image itself to the recipient.
And when I send it to myself, It puts the "X" mark but I get an option to download pictures on right click and it gets the Image.
What I would like to do is, put the Image instead of the "X" for both the cases without the user having to have access to that Image.
How can I do this using Python. The solution in here seems to be working with VBA : https://www.experts-exchange.com/questions/26481413/Problem-inserting-HTML-images-into-the-body-of-a-messge.html
I managed to get this to work through attachment.PropertyAccessor.SetProperty function.
def send_email(sender,recipient):
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = Subject_Req
attachment = mail.Attachments.Add(signatureimage)
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "MyId1")
mail.HTMLBody = Content_Email + "<html><body><img src=""cid:MyId1""></body></html>"
mail.SentOnBehalfOfName = sender
mail.GetInspector
mail.Send()
#Change the Paths here, if ran from a different location
signatureimage = "C:\\Users\\Sid\\AppData\\Roaming\\Microsoft\\Signatures\\My Project\\image001.png"
This would mean, it will embed the Image and not link the Picture to a link. Linking to a picture expects the recipients to have access to that particular picture location.
Also, for a learning this link doesn't change at all :- http://schemas.microsoft.com/mapi/proptag/0x3712001F
Pastebin - My Full Code
I have an issue with my program that effects my entry fields.
With my password entry it works great, the input is stored to a StringVar and can be used to test whether it has been entered correctly.
When users enter an email address or new password in the admin settings page it doesn't work, the text variable is always null.
If you could help that would be much appreciated as this is going towards an important qualification.
Problematic Areas:
Change Function
#Function that changes the system email address
def ChangeEmail(page):
global field_ChangeEmail
newEmail = field_ChangeEmail.get()
field_ChangeEmail.set('')
print(newEmail)
settingsDB = sqlite3.connect('Settings.db')
action = ("UPDATE ADMIN_SETTINGS set SYSTEM_EMAIL = '" + newEmail + "' where ID=1")
settingsDB.execute(action)
settingsDB.commit()
settingsDB.close()
Entry Field
global field_ChangeEmail
entry_ChangeEmail = tk.Entry(page, textvariable = field_ChangeEmail, justify = CENTER, fg = settings_EntryFontColour, font = settings_EntryFont)
widthRatio = settings_AS_Column03Width
heightRatio = settings_AS_RowHeight
relativeX = settings_AS_Column03RelX
relativeY = settings_AS_Row01RelY - 0.0009
entry_ChangeEmail.place(width=screenWidth*widthRatio, height=screenHeight*heightRatio, relx=relativeX, rely=relativeY, x=-((screenWidth*widthRatio)*0.5), y=-((screenHeight*heightRatio)*0.5))
There is nothing wrong with the code you posted, though your use of place and variables for sizing is very, very odd. I strongly encourage you to learn about pack or grid, it will make your GUI much, much easier to get right, and to maintain it over time. Place should never be used except when neither of the other two will work.
That being said, when I run the above code, and add a little extra to make it work, it works fine. ChangeEmail prints out the value that is in the entry widget, then clears the entry widget by setting the variable to an empty string. I assume that's what it's supposed to do.
If the text variable is getting set to null (None?), that is happening in some other part of your code.
I have this code below and trying to populate my pdf with values from the database.
PdfPCell points = new PdfPCell(new Phrase("and is therefore entitled to ", arialCertify));
points.Colspan = 2;
points.Border = 0;
points.PaddingTop = 40f;
points.HorizontalAlignment = 1;//0=Left, 1=Centre, 2=Right
// code below needs attention
var cID = "ALFKI";
var xw = Customers.First(p => p.CustomerID ==cID);
table.AddCell(xw.CompanyName.ToString());
I can not figure out where I am going wrong. When I remove the code under 'code below needs attention' it works but I need the database values.
I am using webmatrix with ItextSharp. If to answer you need further code please let me know.
PdfPCell cell=new PdfPCell(new Phrase(xw.CompanyName.ToString()));
cell.setColspan(numColumns);
table.addCell(cell);
document.add(table);
In my WPF program I have:
string queryString = "Select AccountID, ProjectName from Foo where IsEnabled = 1";
SqlDataAdapter adapter = new SqlDataAdapter(queryString, sConn1);
DataSet dsAccounts = new DataSet();
adapter.Fill(dsAccounts, "Accounts");
cbAccount.ItemsSource = dsAccounts.Tables["Accounts"].AsEnumerable();
cbAccount.DisplayMemberPath = "ProjectName";
When my program runs and I dropdown the ComboBox all the rows are there but they display as blanks. When I click on a row, my SelectionChanged event handler properly identifies the selected row and picks up the proper values.
I believe my problem is with the DisplayMemberPath.
What am I doing wrong?
This is not an answer but rather a workaround. This works:
cbAccount.DataContext = dsAccounts.Tables["Accounts"];
//cbAccount.ItemsSource = dsAccounts.Tables["Accounts"].AsEnumerable();
cbAccount.DisplayMemberPath = "ProjectName";
By setting the DataContext reather than the ItemSource then the DisplayMemberPath is being set properly.
The question remains open, there must be a way to properly set the DisplayMemberPath when one has an ItemSource rather than a DataContext.
I believe the problem is that your table accounts is not serialized to objects.
If you use a list of accounts instead of your tables then it works perfect with the ItemsSource and DisplayMemeberPath.